User-166373564 posted
HI mnmhemaj
To achieve checking for if a user exists. You can use
PrincipalContext to authenticate user credentials,
public bool DoesUserExist(string userName)
{
using (var domainContext = new PrincipalContext(ContextType.Domain, "DOMAIN"))
{
using (var foundUser = UserPrincipal.FindByIdentity(domainContext, IdentityType.SamAccountName, userName))
{
return foundUser != null;
}
}
}
Moreover, you can also check relevant topics about
user existed in Active Directory asp.net online, more examples are available for you.
Best regards
Angie