简体   繁体   English

我可以添加要在UserPrincipal中加载的Active Directory属性吗?

[英]Can I add Active Directory properties to be loaded in UserPrincipal?

Using the DirectorySearcher we can specify which properties can be loaded when searching in the AD. 使用DirectorySearcher,我们可以指定在AD中搜索时可以加载的属性。

    DirectorySearcher dsLookForDomain = new DirectorySearcher(deBase);
    dsLookForDomain.PropertiesToLoad.Add("msDS-PrincipalName"); 

I'm interested in loading msDS-PrincipalName property. 我对加载msDS-PrincipalName属性感兴趣。 Is this possible? 这可能吗?

I'm not sure if this is going to help anynone but I found an alternative to the msDS-PrincipalName. 我不确定这是否对您有帮助,但是我找到了msDS-PrincipalName的替代方法。

    userPrincipal.Sid.Translate(typeof (NTAccount)).ToString()

This will return the same thing the property mentioned above does which is: DOMAIN\\Username 这将返回上述属性所做的相同操作: DOMAIN \\ Username

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Active Directory UserPrincipal问题 - Active Directory UserPrincipal issue 来自Active Directory的UserPrincipal - UserPrincipal from Active Directory 在 UserPrincipal 上调用 Save function 时将用户添加到 Active Directory 异常 - Add user to Active Directory Exception while calling Save function on UserPrincipal 使用PrincipalContext搜索Active Directory组时,不会返回某些UserPrincipal属性 - When Searching Active Directory Groups Using PrincipalContext Certain UserPrincipal Properties are not Returned UserPrincipal对象,Active Directory查询:DirectoryServicesCOMException - UserPrincipal Object, Active Directory Query: DirectoryServicesCOMException 为了通过C#UserPrincipal在Active Directory中设置UserCannotChangePassword,我必须具有哪些权限才能委派 - What permissions do I have to delegate in order to set UserCannotChangePassword in Active Directory through a C# UserPrincipal 如何在C#中的Active Directory中的UserPrincipal对象上设置管理器属性 - How do I set the Manager Attribute on the UserPrincipal object in Active Directory in C# 尝试访问 Active Directory 中的属性以添加到数据库 - Trying to access Properties in Active Directory to add to a Database 给定一个UserPrincipal对象,如何从Active Directory中获取“公司”和“部门”? - How to get “Company” and “Department” from Active Directory given a UserPrincipal object? C# Active Directory PrincipalContext / UserPrincipal.IsMemberOf 错误 - C# Active Directory PrincipalContext / UserPrincipal.IsMemberOf error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM