首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >DirectoryEntry属性

DirectoryEntry属性
EN

Stack Overflow用户
提问于 2013-07-26 16:05:33
回答 1查看 20K关注 0票数 0

我对我的C#项目有一个简短的要求。我想读出我们的active directory并使用下面的代码:

代码语言:javascript
复制
System.DirectoryServices.DirectorySearcher mySearcher = new System.DirectoryServices.DirectorySearcher(entry);

foreach (System.DirectoryServices.SearchResult resEnt in mySearcher.FindAll())
{
        System.DirectoryServices.DirectoryEntry de = resEnt.GetDirectoryEntry();
        try
        {
            myRow["eMail"] = de.Properties["Mail"].Value.ToString();
        }
        catch (Exception)
        { }
}

现在我想读出其他属性,希望您能给我一个所有属性的列表。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2013-07-27 12:50:44

你可以通过下面的代码简单地做到这一点

代码语言:javascript
复制
 DirectorySearcher mySearcher = new System.DirectoryServices.DirectorySearcher(entry);

            foreach (System.DirectoryServices.SearchResult resEnt in mySearcher.FindAll())
            {
                try
                {
                    foreach (string property in resEnt.Properties.PropertyNames)
                    {
                        string value = resEnt.Properties[property][0].ToString();

                        Console.WriteLine(property + ":" + value);
                    }
                }
                catch (Exception)
                { }
            }
票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17876118

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档