We recently deployed a web application here on our intranet which uses Windows authentication. During development, on an XP machine, the application worked fine. When we pushed it into production on a 2003 server machine, we started getting this error:
The directory datatype cannot be converted to/from a native DS datatype
The thing was, the application would work for a while and then stop working. Well, we tracked this issue down to the following problem, discussed in KB Article 241981:
“With ADSI version 2.0, ADSI forces a schema cache update every time ADSI fails to get the syntax of attribute from the LDAP server, which is represented by the error message above. In ADSI version 2.5, the dynamic schema cache update was removed for performance reasons, and because the forced refresh was thrashing the RootDSE on LDAP version 2.0 servers“
The problem with this KB article is that it discusses how to manually refresh the schema cache, but it's in loosely typed script code. So, after some research, I found a method of the SchemaEntry object that will do the refreshing. Here's one example of how to to do this:
public string GetProperty(DirectoryEntry de, string PropertyName)
{
de.SchemaEntry.RefreshCache(
new string [] {PropertyName});
if(de.Properties.Contains(PropertyName)){
return de.Properties[PropertyName][0].ToString() ;
}
return null;
}
This works, but we found that the web server also had to be “Trusted for Delegation“ by the domain controller machine. Now, I had our network guy do this, and the combination of the Schema refresh and the trusting did the trick!
-Brendan