Reads information about a replica. The information available includes such items as replicas state, last modification time, and replica type. To read other information about a replica, you must create an instance of this class and then call the extendedOperation method with this object as the required LdapExtendedOperation parameter. The getReplicaInfoRequest extension uses the following OID: 2.16.840.1.113719.1.27.100.17 The requestValue has the following format: requestValue ::= serverDN LdapDN partitionDN LdapDN
Inheritance: Novell.Directory.Ldap.LdapExtendedOperation
Exemplo n.º 1
0
    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());
        }
    }
Exemplo n.º 2
0
    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());
        }
    }