相关疑难解决方法(0)


如何使用System.DirectoryServices.AccountManagement命名空间获取Active Directory用户属性?

我想从用户获取Active Directory属性,我想使用System.DirectoryServices.AccountManagement.

我的代码:

public static void GetUserProperties(string dc,string user) 
        {
            PrincipalContext ctx = new PrincipalContext(ContextType.Domain, dc);
            UserPrincipal u = UserPrincipal.FindByIdentity(ctx, user);

            string firstname = u.GivenName;
            string lastname = u.Surname;
            string email = u.EmailAddress;
            string telephone = u.VoiceTelephoneNumber;

            ...//how I can get company and other properties?
        }
Run Code Online (Sandbox Code Playgroud)

c# properties active-directory principal userprincipal

7
推荐指数
1
解决办法
2万
查看次数