【问题标题】:Access to property in UserPrincipal访问 UserPrincipal 中的属性
【发布时间】:2013-09-03 18:16:22
【问题描述】:

我有一个 DirectoryServices.AccountManagement.UserPrincipal 对象。 我看到在它中使用 Visual Studio 的一些属性,但我可以访问它们。

例如,我如何访问属性 EmailAddress? 有可能吗?

member.Something.EmailAddress

?

更新

EmailAddress 无法直接访问:

【问题讨论】:

    标签: c# .net active-directory


    【解决方案1】:

    只需使用member.EmailAddress ....

    查看您可以直接访问的this MSDN page for a complete list of all properties on UserPrincipal - 而EmailAddress 绝对是其中之一!

    更新:你是说你不能直接访问.EmailAddress...你真的在处理UserPrincipal 对象吗?

    试试这个:

    UserPrincipal up = (member as UserPrincipal);
    
    if (up != null)
    {
       string email = up.EmailAddress;
    }
    

    您可以访问up 对象上的.EmailAddress 属性吗??

    【讨论】:

    • 谢谢,但它不是可用的之一。看看我刚刚在问题中更新的图像。
    • @RicardoPolo member 的数据类型是什么,是 UserPricipal 还是只是 Principal?您可能需要投射它。
    • @RicardoPolo:更新了我的回复 - 你可以试试我的建议吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-12
    • 2019-05-19
    • 1970-01-01
    • 2019-07-05
    • 1970-01-01
    • 1970-01-01
    • 2015-11-03
    相关资源
    最近更新 更多