LDAP Problems updating LDAP information: saving attribute values gives error: 0x8000500C - The Active Directory Datatype Cannot be Converted to/from a Native DS Datatype / LDAPConnection: The LDAP server is unavailable

Our customer had the wish to synchronise some Sharepoint UserProfileProperties of UserProfiles back to LDAP, so that information could be synced with SAP. The attributes that needed to be saved, where inherited from custom schemas in LDAP, which gave us some trouble. When updating attribute values in LDAP, and they inherit from the default scheme, there is really no problem. But at the moment that we tried to update an attribute that inherited from a custom schema, we saw some very weird behaviour:

private void UpdateAttribute(SearchResult sr)

        {

            DirectoryEntry de = sr.GetDirectoryEntry();

            if(de.Properties.Contains("customProperty"))

            {

                de.Properties["customProperty"][0] = "bla";

            }

            de.CommitChanges();

        }

threw a com exception: 0x8000500C - The Active Directory Datatype Cannot be Converted to/from a Native DS Datatype. It even threw the exception at the line:

if(de.Properties.Contains("customProperty"))

 When trying to access a property that didn't exist or a property that inherited from the default schema, no exception was thrown. What is the case? There are 2 possibilities:

1) the schema cache can't be updated on our machine, and with the lack of a correct schema, the datatype couldn't be converted.
2) For some reason, LDAP V2 is used instead of V3, which has the problem that custom attributes can't be loaded

We didn't find a solution for this, but googled brought me an alternative solution:

the System.DirectoryServices.Protocols namespace!
I tried to make a connection to the LDAP server with the following Code:

LdapDirectoryIdentifier id = new LdapDirectoryIdentifier("LDAP://" + ConfigurationManager.AppSettings["LdapServer"], 389);

LdapConnection _LdapConnection = new LdapConnection(id, AuthType.Basic);

            _LdapConnection.SessionOptions.ProtocolVersion = 3;

            _LdapConnection.Bind(); 

But this threw another error: The LDAP server is unavailable. 2 hours of trial and error brought me to the conclusion: leave the "LDAP://" when specifying the server :S

Using LdapDirectoryIdentifier id = new LdapDirectoryIdentifier(ConfigurationManager.AppSettings["LdapServer"], 389); everything worked fina, and now we have a 2-way working synchronization between a LDAP store and a SharePoint UserProfileStore!

 

Published Fri, May 22 2009 5:19 PM by Bas

Comments

# re: LDAP Problems updating LDAP information: saving attribute values gives error: 0x8000500C - The Active Directory Datatype Cannot be Converted to/from a Native DS Datatype / LDAPConnection: The LDAP server is unavailable

Saturday, May 23, 2009 12:52 PM by all_ldap_all_the_time

The sooner we stop thinking of AD as a directory server, the better off we will be, and the further along the path to holistic identity management, at which point humanity will be much improved. Users who wish to use LDAP should use professional software like DSEE or OpenDS, not the toys from Microsoft. Case in point: your problems had nothing whatever to do with LDAP, they were purely caused by poorly constructed software of a dubious design - in this case from Microsoft.

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Please add 4 and 4 and type the answer here: