Oracle & Active Directory : A love/hate relationship
        Posted  
        
            by Frank
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Frank
        
        
        
        Published on 2010-03-29T18:52:56Z
        Indexed on 
            2010/03/30
            12:33 UTC
        
        
        Read the original article
        Hit count: 905
        
Hi SO'ers,
I'm currently trying to access Active Directory via the dbms_ldap API in Pl/Sql (Oracle). The trouble is that I'm not able to connect with my own username and password or anynoymously.
However, in C# I can connect anonymously with this code :
DirectoryEntry ldap = new DirectoryEntry("LDAP://Hostname");
DirectorySearcher searcher = new DirectorySearcher(ldap);
searcher.Filter = "(SAMAccountName=username)";
SearchResult result = searcher.FindOne();
If I try to connect anonymously in Oracle, I only get the error(ORA-31202 : LDAP client/server error) when I try to search (and the result code for the bind is SUCCESS)...
my_session := dbms_ldap.init('HOST','389');
retval := dbms_ldap.simple_bind_s(my_session, '', '');
retval := dbms_ldap.search_s(my_session, ldap_base,  dbms_ldap.scope_subtree, 'objectclass=*', my_attrs, 0, my_message);
Why is the anonymous connection is C# works but doesn't work in Pl/Sql? Do you have any other idea to connect to Active Directory via Oracle?
Help me reunite them together.
 Thanks.
Edit
When I bind with anonymous credentials I get : 
ORA-31202: DBMS_LDAP: LDAP client/server error
00000000: LdapErr: DSID-0C090627, comment: In order to perform this operation a successful bind must be completed on the >connection
And if I try to connect with my credentials, which are supposed to be valid since I'm connected to the domain with it... I get : 
ORA-31202: DBMS_LDAP: LDAP client/server error Invalid credentials
80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error
© Stack Overflow or respective owner