im trying to inquire Ad by using this line`s
DirectoryEntry de = null;
SearchResult results = null;
de = new DirectoryEntry();
//geting the result FROM ad
de.Path = dr.manager;
de.AuthenticationType = AuthenticationTypes.Secure;
DirectorySearcher search = new DirectorySearcher(de);
search.Filter = string.Format("(objectClass={0})",'*');
search.PropertiesToLoad.Add("IsraelID");
results = search.FindOne();
de = results.GetDirectoryEntry();
but im getting an exception in the findone()
System.Runtime.InteropServices.COMException (0x80004005): Unspecified error
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne)
at System.DirectoryServices.DirectorySearcher.FindOne()
acutely my mistake was much more basic than the exception mentioned .. i wrote this wrong active directory statement
when i added "LDAP://" to the statement it solve it
thanks allot for the support
Note: The string.Concat() around the "(objectClass=*)" statement is there because It's common to add additional statements or variables there.
Make sure you have a proper LDAP string, and I would suggest using statements to make sure you dispose of everything afterwards.
Unspecified error means, that your LDAP path is missing the LDAP protocol identifier. Ensure that your path contains the LDAP protocol identifier in upper case.
Example:
Hope, this helps.
try yhis way :
In this case I authenticate as a user and a password. If you run the program from a computer inside the domain, you don't need to authenticate. You've got a good sample here.