how to look up a user by email in AD

  • Thread starter Thread starter msdnpublic1234
  • Start date Start date
M

msdnpublic1234

Guest
Hi,

I have a condition for few users where the mail address is misspelt in the front end application due to which i see a mismatch when i try to send email to these users,I get exception.

How to check if a user is existing in the AD by looking up his email?

I started doing the below,but then unfortunately realized that the I couldnt search by email as IdentityType allows only few properties from the AD.

public bool CheckUserExist(string Mail)
{
using (var domainContext = new PrincipalContext(ContextType.Domain, "abc", "xyz1234", "test"))
{
using (var foundUser = UserPrincipal.FindByIdentity(domainContext, IdentityType.SamAccountName, ?))
{
return foundUser!=null;
}
}
}

Continue reading...
 
Back
Top