Returns the distingusihed name of the object your are logged in as. To use this class, you must create an instance of the class and then call the extendedOperation method with this object as the required LdapExtendedOperation parameter. The returned LdapExtendedResponse object can then be converted to a GetBindDNResponse object with the ExtendedREsponseFactory class. This object contains methods for retrieving the distinguished name. The GetBindDNRequest extension uses the following OID: 2.16.840.1.113719.1.27.100.31 The request value has a value of null.
Inheritance: Novell.Directory.Ldap.LdapExtendedOperation
Exemplo n.º 1
0
    public static void  Main(System.String[] args)
    {
        if (args.Length != 4)
        {
            System.Console.Error.WriteLine("Usage:   mono GetBindDN " + "<host Name> <port number> <login dn>" + "\n              <password>");
            System.Console.Error.WriteLine("Example: mono GetBindDN Acme.com " + "389 \"cn=Admin,o=Acme\" secret");
            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];
        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 GetBindDNRequest();

            LdapExtendedResponse response = ld.ExtendedOperation(request);

            if (((response.ResultCode) == LdapException.SUCCESS) && (response is GetBindDNResponse))
            {
                System.Console.Out.WriteLine("You were logged in as: " + ((GetBindDNResponse)response).Identity);
                System.Console.Out.WriteLine("\nGetBindDN succeeded.\n");
            }
            else
            {
                System.Console.Out.WriteLine("GetBindDN failed.\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("\nError: " + e.LdapErrorMessage);
        }
    }
Exemplo n.º 2
0
    public static void Main(System.String[] args)
    {
        if (args.Length != 4)
        {
            System.Console.Error.WriteLine("Usage:   mono GetBindDN " + "<host Name> <port number> <login dn>" + "\n              <password>");
            System.Console.Error.WriteLine("Example: mono GetBindDN Acme.com " + "389 \"cn=Admin,o=Acme\" secret");
            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];
        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 GetBindDNRequest();

            LdapExtendedResponse response = ld.ExtendedOperation(request);

            if (((response.ResultCode) == LdapException.SUCCESS) && (response is GetBindDNResponse))
            {
                System.Console.Out.WriteLine("You were logged in as: " + ((GetBindDNResponse) response).Identity);
                System.Console.Out.WriteLine("\nGetBindDN succeeded.\n");
            }
            else
            {
                System.Console.Out.WriteLine("GetBindDN failed.\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("\nError: " + e.LdapErrorMessage);
        }
    }