C# : Error while accessing Active Directory
Posted
by Mohsan
on Stack Overflow
See other posts from Stack Overflow
or by Mohsan
Published on 2009-11-17T10:16:06Z
Indexed on
2010/04/15
13:03 UTC
Read the original article
Hit count: 563
c#
|active-directory
hi. i am facing some problems in accessing Active Directory from my winform app. what I want is to create a user and query user from Active Directory.
here is code snippet for find user
public bool FindUser(string username)
{
using (PrincipalContext context = new PrincipalContext(ContextType.Domain, this.domainName, this.DomainUserName, this.DomainPassword))
{
UserPrincipal user = UserPrincipal.FindByIdentity(context, username);
return (user != null) ? true : false;
}
}
i am unable to create object of PrincipalContext based on given arguments. i am getting this exception "{"The server could not be contacted."}"
and inner exception states that "{"The LDAP server is unavailable."}"
where as domain is running. i can ping to it and can also connect to this domain.
any suggestion about these exceptions?
© Stack Overflow or respective owner