locked
Active Directory and VB.NET RRS feed

  • Question

  • User-809753952 posted

    How to check if a user is in a Distribution Group (Not windows security group)  in the Active Directory?

    Thursday, December 19, 2013 12:43 PM

Answers

  • 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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 26, 2013 12:30 AM