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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.