相关疑难解决方法(0)


我可以使用 PrincipalContext() 从 Active Directory 获取用户部门吗

我正在尝试从 Active Directory 获取用户的部门。我有以下课程:

public class DomainContext
{
        public string DisplayName { get; set; }
        public string Name { get; set; }
        public string SamAccountName { get; set; }
        public string DistinguishedName { get; set; }
        public string UserPrincipalName { get; set; }
        public string Department { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

然后使用下面的方法,我可以获取用户名、显示名、sam 帐户等....

public override void getUserDepts(SPItemEventProperties properties)
{
    base.ItemUpdating(properties);

    string[] offices = new string[] { "OfficeA", "OfficeB", "OfficeC" };

    string ADServerName = "*****";
    string ADusername = "******";
    string ADpassword …
Run Code Online (Sandbox Code Playgroud)

c# asp.net directoryservices userprincipal

3
推荐指数
1
解决办法
3568
查看次数