我正在寻找一种简单的方法将所有活动目录用户信息导出到每个用户的唯一vcards中。有一些信息我想离开vcard,如家庭电话和紧急联系。我环顾网络,没有找到任何运气。任何帮助,将不胜感激。
答案 0 :(得分:0)
我怀疑会有一个非常简单的方法。最终,你需要
搜索&迭代部分,您可以使用PrincipalSearcher
进行搜索:
// create your domain context
using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain))
{
// define a "query-by-example" principal - here, we search for a UserPrincipal
// this "QBE" user would give you the ability to further limit what you get back
// as results from the searcher
UserPrincipal qbeUser = new UserPrincipal(ctx);
// create your principal searcher passing in the QBE principal
PrincipalSearcher srch = new PrincipalSearcher(qbeUser);
// find all matches
foreach(var found in srch.FindAll())
{
UserPrincipal foundUser = found as UserPrincipal;
if(foundUser != null)
{
ExportToVCard(foundUser);
}
}
}
现在剩下要做的就是创建ExportToVCard
函数:-)请参阅e.g. this blog post with code samples and further links寻求帮助。
如果您还没有 - 绝对阅读MSDN文章Managing Directory Security Principals in the .NET Framework 3.5,该文章很好地展示了如何充分利用System.DirectoryServices.AccountManagement
中的新功能。或者查看MSDN documentation on the System.DirectoryServices.AccountManagement命名空间。
答案 1 :(得分:0)
如果你只想要数据本身,我会看一下Softerra的免费LDAP浏览器found here。
为目录服务器设置配置文件 - 一旦在浏览器中连接,您将看到在初始设置期间提供的BaseDN的默认架构。在服务器图标上,右键单击,然后单击“导出数据”。
导出向导将引导您完成大部分过程,但重要的部分是步骤3.如果您要查找所有用户,只需将搜索过滤器设置为(objectClass=user)
,请确保您的搜索范围是SubTree ,然后编辑要返回的属性。
您必须将结果处理为VCards,但这是获取所需用户和属性的最简单\最快的方法。