H
Hechmi
I am trying to retrieve the users of the company using active directory.
When i execute the code below , it gives the following error
"The Active Directory datatype cannot be converted to/from a native DS
datatype"
could anyone help me with this please. i already passed two days trying to
figure out what is the problem.
thank you very much
the code is in J#
/**************************************************/
private System.DirectoryServices.DirectoryEntry root;
private System.DirectoryServices.DirectorySearcher ds;
private System.DirectoryServices.SearchResultCollection src;
private System.DirectoryServices.SearchResult result;
private System.DirectoryServices.DirectoryEntry user;
root = new
System.DirectoryServices.DirectoryEntry(LDAP_ROOT,LDAP_NAME,LDAP_PASS);
ds = new System.DirectoryServices.DirectorySearcher(root);
ds.set_CacheResults(true);
ds.set_Filter("(&(objectCategory=Person)(objectClass=user))");
src = ds.FindAll();
for(int i=0 ;i<totalRows ;i++)
{
result = (System.DirectoryServices.SearchResult) src.get_Item(i);
user = result.GetDirectoryEntry();
if(user != null)
{
user.get_Properties().get_Item("givenName").get_Value().ToString();
}
}
When i execute the code below , it gives the following error
"The Active Directory datatype cannot be converted to/from a native DS
datatype"
could anyone help me with this please. i already passed two days trying to
figure out what is the problem.
thank you very much
the code is in J#
/**************************************************/
private System.DirectoryServices.DirectoryEntry root;
private System.DirectoryServices.DirectorySearcher ds;
private System.DirectoryServices.SearchResultCollection src;
private System.DirectoryServices.SearchResult result;
private System.DirectoryServices.DirectoryEntry user;
root = new
System.DirectoryServices.DirectoryEntry(LDAP_ROOT,LDAP_NAME,LDAP_PASS);
ds = new System.DirectoryServices.DirectorySearcher(root);
ds.set_CacheResults(true);
ds.set_Filter("(&(objectCategory=Person)(objectClass=user))");
src = ds.FindAll();
for(int i=0 ;i<totalRows ;i++)
{
result = (System.DirectoryServices.SearchResult) src.get_Item(i);
user = result.GetDirectoryEntry();
if(user != null)
{
user.get_Properties().get_Item("givenName").get_Value().ToString();
}
}