6

MVC .Net 3.5 に Web サイトがあります。コントローラーで以下のコードを使用する必要があります。だから私は名前空間を参照しています

System.DirectoryServices.AccountManagement

そして、私はエラーを受け取ります:

Error   1   The type or namespace name 'DirectoryServices' does not exist in the namespace 'System' (are you missing an assembly reference?)

不足しているアセンブリとプロジェクトに追加する方法を教えてください。

        // 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;
        }
4

1 に答える 1

21

System.DirectoryServices.AccountManagement.dllこの名前空間が存在するアセンブリへの参照を追加したことを確認してください。

参考までに:PrincipalContext

于 2012-10-15T06:08:08.187 に答える