#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Location
    Wash DC, USA
    Posts
    44
    Rep Power
    10

    C#/.NET4 - SunONe DSv5 Bind issue


    Hello Folks,
    I am trying to code a C#/.NET4 program to connect to a UNIX LDAP server running SunOne Directory Services v5.2. I am unable to BIND() to the server and get a run error:
    The object does not exist
    I believe that I have an issue with specifying my user id and would appreciate any suggestions anyone may have.
    my code
    Code:
    // ldapuid.cs - demo program to test connection to Unix LDAP Server (SunOne Directory Server 5.2)
    // csc ldapuid.cs /r:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\System.DirectoryServices.Protocols.dll
    // ldapuid
    using System;
    using System.IO;
    using System.DirectoryServices.Protocols;
    using System.Net;
    
    namespace Foo.test {
    class LdapTest
    {
    	static void Main(string[] args)
        {
    NetworkCredential credential = new NetworkCredential("uid=user123,ou=people,ou=corporate,dc=foo,dc=com", "pass123");
    LdapDirectoryIdentifier identifier = new LdapDirectoryIdentifier("192.168.1.100:389");
    LdapConnection ldap = new LdapConnection (identifier, credential, System.DirectoryServices.Protocols.AuthType.Basic);
    ldap.SessionOptions.ProtocolVersion = 3;  // Set protocol to LDAPv3
    Console.WriteLine("Bind() to LDAP server");
    try {
    	ldap.Bind();
    	}
    catch (Exception ex){		
    	System.Console.WriteLine("LDAP Bind() Exception detected!:\n" + ex);
    	System.Console.WriteLine("\nMessage: " + ex.Message);
    	Environment.Exit(1) ;	//terminate program because of a fatal error.
    }
    
    Console.WriteLine("Bind() completed.");
    
    	}		//end-Main
    }		//end-Class
    }		//end-Namespace
    Execution:
    Bind() to LDAP server
    LDAP Bind() Exception detected!:
    System.DirectoryServices.Protocols.DirectoryOperationException: The object does not exist.
    at System.DirectoryServices.Protocols.LdapConnection.BindHelper(NetworkCredential newCredential, Boolean needSetCredential)
    at Fanniemae.test.LdapTest.Main(String[] args)

    Message: The object does not exist.

    Thanks for any help!!
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Location
    Wash DC, USA
    Posts
    44
    Rep Power
    10
    Resolved!!! - The LDAP admin gave me the wrong port, its not using the default port of 389 - it was using a different port. So once I updated the port the BIND() worked perfectly.

IMN logo majestic logo threadwatch logo seochat tools logo