public static void Main(System.String[] args) { if (args.Length != 6) { System.Console.Error.WriteLine("Usage: mono GetReplicaInfo <host Name> " + "<port number> <login dn> <password>\n " + " <partition DN> <server ND>"); System.Console.Error.WriteLine("Example: mono GetReplicaInfo Acme.com 389 " + "\"cn=Admin,o=Acme\" secret\n " + "\"ou=Sales,o=Acme\" \"cn=myServer,o=Acme\""); System.Environment.Exit(1); } int ldapVersion = LdapConnection.Ldap_V3; System.String ldapHost = args[0]; int ldapPort = System.Int32.Parse(args[1]); System.String loginDN = args[2]; System.String password = args[3]; System.String partitionDN = args[4]; System.String serverDN = args[5]; int intInfo; System.String strInfo; LdapConnection ld = new LdapConnection(); try { // connect to the server ld.Connect(ldapHost, ldapPort); // bind to the server ld.Bind(ldapVersion, loginDN, password); System.Console.Out.WriteLine("\nLogin succeeded"); LdapExtendedOperation request = new GetReplicaInfoRequest(serverDN, partitionDN); LdapExtendedResponse response = ld.ExtendedOperation(request); if ((response.ResultCode == LdapException.SUCCESS) && (response is GetReplicaInfoResponse)) { System.Console.Out.WriteLine("Repica Info:"); strInfo = ((GetReplicaInfoResponse)response).getpartitionDN(); System.Console.Out.WriteLine(" Partition DN: " + strInfo); intInfo = ((GetReplicaInfoResponse)response).getpartitionID(); System.Console.Out.WriteLine(" Partition ID: " + intInfo); intInfo = ((GetReplicaInfoResponse)response).getreplicaState(); System.Console.Out.WriteLine(" Replica state: " + intInfo); intInfo = ((GetReplicaInfoResponse)response).getmodificationTime(); System.Console.Out.WriteLine(" Modification Time: " + intInfo); intInfo = ((GetReplicaInfoResponse)response).getpurgeTime(); System.Console.Out.WriteLine(" Purge Time: " + intInfo); intInfo = ((GetReplicaInfoResponse)response).getlocalPartitionID(); System.Console.Out.WriteLine(" Local partition ID: " + intInfo); intInfo = ((GetReplicaInfoResponse)response).getreplicaType(); System.Console.Out.WriteLine(" Replica Type: " + intInfo); intInfo = ((GetReplicaInfoResponse)response).getflags(); System.Console.Out.WriteLine(" Flags: " + intInfo); System.Console.Out.WriteLine("\nget replica information succeeded\n"); } else { System.Console.Out.WriteLine("Could not get replica information.\n"); throw new LdapException(response.ErrorMessage, response.ResultCode, (System.String)null); } /* Done, so disconnect */ if (ld.Connected) { ld.Disconnect(); } } catch (LdapException e) { System.Console.Out.WriteLine("Error: " + e.ToString()); } }
public static void Main(System.String[] args) { if (args.Length != 6) { System.Console.Error.WriteLine("Usage: mono GetReplicaInfo <host Name> " + "<port number> <login dn> <password>\n " + " <partition DN> <server ND>"); System.Console.Error.WriteLine("Example: mono GetReplicaInfo Acme.com 389 " + "\"cn=Admin,o=Acme\" secret\n " + "\"ou=Sales,o=Acme\" \"cn=myServer,o=Acme\""); System.Environment.Exit(1); } int ldapVersion = LdapConnection.Ldap_V3; System.String ldapHost = args[0]; int ldapPort = System.Int32.Parse(args[1]); System.String loginDN = args[2]; System.String password = args[3]; System.String partitionDN = args[4]; System.String serverDN = args[5]; int intInfo; System.String strInfo; LdapConnection ld = new LdapConnection(); try { // connect to the server ld.Connect(ldapHost, ldapPort); // bind to the server ld.Bind(ldapVersion, loginDN, password); System.Console.Out.WriteLine("\nLogin succeeded"); LdapExtendedOperation request = new GetReplicaInfoRequest(serverDN, partitionDN); LdapExtendedResponse response = ld.ExtendedOperation(request); if ((response.ResultCode == LdapException.SUCCESS) && (response is GetReplicaInfoResponse)) { System.Console.Out.WriteLine("Repica Info:"); strInfo = ((GetReplicaInfoResponse) response).getpartitionDN(); System.Console.Out.WriteLine(" Partition DN: " + strInfo); intInfo = ((GetReplicaInfoResponse) response).getpartitionID(); System.Console.Out.WriteLine(" Partition ID: " + intInfo); intInfo = ((GetReplicaInfoResponse) response).getreplicaState(); System.Console.Out.WriteLine(" Replica state: " + intInfo); intInfo = ((GetReplicaInfoResponse) response).getmodificationTime(); System.Console.Out.WriteLine(" Modification Time: " + intInfo); intInfo = ((GetReplicaInfoResponse) response).getpurgeTime(); System.Console.Out.WriteLine(" Purge Time: " + intInfo); intInfo = ((GetReplicaInfoResponse) response).getlocalPartitionID(); System.Console.Out.WriteLine(" Local partition ID: " + intInfo); intInfo = ((GetReplicaInfoResponse) response).getreplicaType(); System.Console.Out.WriteLine(" Replica Type: " + intInfo); intInfo = ((GetReplicaInfoResponse) response).getflags(); System.Console.Out.WriteLine(" Flags: " + intInfo); System.Console.Out.WriteLine("\nget replica information succeeded\n"); } else { System.Console.Out.WriteLine("Could not get replica information.\n"); throw new LdapException(response.ErrorMessage, response.ResultCode, (System.String) null); } /* Done, so disconnect */ if (ld.Connected) ld.Disconnect(); } catch (LdapException e) { System.Console.Out.WriteLine("Error: " + e.ToString()); } }