Search code examples
c#ldapldapconnection

C# Connection to Oracle Identity Management LDAP Server


We are working with another company whom has a Oracle Identity Management Server setup. We are to connect to this and authenticate users based on LDAP data retried from the server.

We have tried to plug into this by using an LdapConnection object passing in the server name and port along with the Network credentials they are providing to us so we are using a AuthType of Basic. However on the Bind() we are always failing because it says that we have invalid credentials. We have worked with the client to make sure they are correct and we have been able to log in to Oracle Identity Management with the credentials, although the user name we had to use data from the SearchRequests distinguished name. But even using that we keep on receiving the same error. Client is also using the credentials to connect via Java.

This is an issue where as I think there is no solution really, but does anyone out there have any idea on how to go about doing this? We have the same code running which is working and pulling from Active Directory. So our code should be fine as long as Oracle supports connecting in this fashion. But finding anything in regards to this topic is like pulling teeth.

Anyone have any experience with this out there? Please let me know I would be happy to provide any additional details if needed.

Thanks in advance!


Solution

  • I recently fumbled through connecting to OID using LDAP. Here's the code that ended up working for me:

    // make sure the server and port are correct
    using (var ldap = new LdapConnection("ldap.company.com:3060"))
    {
        // make sure to pass the username as a distinguishedName
        var dn = string.Format("cn={0},cn=users,dc=company,dc=com", username);
    
        // passing null for the domain worked for me
        var credentials = new System.Net.NetworkCredential(dn, password, null);
        ldap.AuthType = AuthType.Basic;
    
        try
        {
            ldap.Bind(credentials);
            return true;
        }
        catch (LdapException ex)
        {
            return false;
        }
    }