Novell.Directory.Ldap.LdapConnection.ExtendedOperation C# (CSharp) Method

ExtendedOperation() public method

Provides a synchronous means to access extended, non-mandatory operations offered by a particular Ldapv3 compliant server.
LdapException A general exception which includes an error /// message and an Ldap error code. ///
public ExtendedOperation ( LdapExtendedOperation op ) : LdapExtendedResponse
op LdapExtendedOperation The object which contains (1) an identifier of an extended /// operation which should be recognized by the particular Ldap /// server this client is connected to and (2) /// an operation-specific sequence of octet strings /// or BER-encoded values. /// ///
return LdapExtendedResponse
        public virtual LdapExtendedResponse ExtendedOperation(LdapExtendedOperation op)
        {
            return ExtendedOperation(op, defSearchCons);
        }

Same methods

LdapConnection::ExtendedOperation ( LdapExtendedOperation op, LdapConstraints cons ) : LdapExtendedResponse
LdapConnection::ExtendedOperation ( LdapExtendedOperation op, LdapConstraints cons, LdapResponseQueue queue ) : LdapResponseQueue
LdapConnection::ExtendedOperation ( LdapExtendedOperation op, LdapResponseQueue queue ) : LdapResponseQueue

Usage Example

    public static void  Main(System.String[] args)
    {
        if (args.Length != 5)
        {
            System.Console.Error.WriteLine("Usage:   mono ListReplicas <host Name> " + "<port number> <login dn> <password>" + "\n         <server ND>");
            System.Console.Error.WriteLine("Example: mono ListReplicas Acme.com 389 " + "\"cn=Admin,o=Acme\" secret" + "\n         \"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  serverDN = args[4];
        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 ListReplicasRequest(serverDN);

            LdapExtendedResponse response = ld.ExtendedOperation(request);

            if ((response.ResultCode == LdapException.SUCCESS) && (response is ListReplicasResponse))
            {
                System.Console.Out.WriteLine("Replica List: ");
                System.String[] rList = ((ListReplicasResponse)response).ReplicaList;
                int             len   = rList.Length;
                for (int i = 0; i < len; i++)
                {
                    System.Console.Out.WriteLine(rList[i]);
                }

                System.Console.Out.WriteLine("\nList replica request succeeded\n");
            }
            else
            {
                System.Console.Out.WriteLine("List Replicas request failed." + response.ResultCode);
//				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("\nError: " + e.ToString());
        }
    }
All Usage Examples Of Novell.Directory.Ldap.LdapConnection::ExtendedOperation