I have a website in MVC .Net 3.5, I need to use the code below in a Controller. So I'm referencing the name space
System.DirectoryServices.AccountManagement
And I receive an error:
Error   1   The type or namespace name 'DirectoryServices' does not exist in the namespace 'System' (are you missing an assembly reference?)
Which assembly Am I missing and how to add it in the project?
        // set up domain context
        PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
        // find a user
        UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "SomeUserName");
        if (user != null)
        {
            // do something here.... 
            string givenName = user.GivenName;
        }
                Make sure you have added reference to the System.DirectoryServices.AccountManagement.dll assembly which is where this namespace lives.
For reference: PrincipalContext.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With