将 Active Directory 用户和组导入 SQL Server(可能通过 c#)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/201235/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 17:46:42  来源:igfitidea点击:

Importing Active Directory Users and Groups into SQL Server (possibly via c#)

c#sql-serveractive-directory

提问by Arry

I need to import all ad groups in a few OUs into a table in SQL Server 2008. Once I have those I need to import all the members of those groups to a different table. I can use c# to do the work and pass the data to SQL server or do it directly in SQL server.

我需要将几个 OU 中的所有广告组导入到 SQL Server 2008 中的一个表中。一旦我有了这些,我需要将这些组的所有成员导入到另一个表中。我可以使用 c# 来完成工作并将数据传递给 SQL Server 或直接在 SQL Server 中执行。

Suggestions on the best way to approach this?

有关解决此问题的最佳方法的建议?

采纳答案by Matthias Meid

Arry,

阿里,

I don't know exactly, but found some links that may help you. I think the hottest track is this expression:

我不知道确切,但找到了一些可能对您有帮助的链接。我认为最热门的曲目是这个表达:

"(&(objectCategory=Person)(memberOf=DN=GroupName, OU=Org, DC=domain,
DC=com))"

I found it in LDAP Query for group memberson a ColdFusion community's site. I'm more or less sure the filter can easily be applied to your query. I'm sorry, but I cannot test it, because I have no AD around here.

我在ColdFusion 社区站点上的组成员的 LDAP 查询中找到了它。我或多或少确定过滤器可以轻松应用于您的查询。我很抱歉,但我无法测试它,因为我这里没有 AD。

This one could also be a bit (but less) interesting:

这个也可能有点(但不那么有趣):

http://forge.novell.com/pipermail/cldap-dev/2004-April/000042.html

http://forge.novell.com/pipermail/cldap-dev/2004-April/000042.html

Hope this helps, cheers,

希望这有帮助,干杯,

Matthias

马蒂亚斯

回答by Matthias Meid

Add a Linked Server to your SQL Server and query the Active Directory via LDAP queries. This here described this quite well:

将链接服务器添加到您的 SQL Server 并通过 LDAP 查询查询 Active Directory。这在这里很好地描述了这一点:

Create a SQL Server View of your AD Users, Brendan Tompkins (MVP)

创建 AD 用户的 SQL Server 视图,Brendan Tompkins (MVP)

回答by billinkc

As the OP of this question seemed open to other technologies (3 years ago), I posted a walk through that uses SSIS as the technology for querying AD for users, writing those users to a table and doing group lookups on those users. Active Directory SSIS Data SourceEven if you aren't interested in SSIS, the LDAP query for source objects and the C# for group membership might be handy for anyone reviewing this question.

由于这个问题的 OP 似乎对其他技术开放(3 年前),我发布了一个使用 SSIS 作为技术来查询用户 AD、将这些用户写入表并对这些用户进行组查找的演练。 Active Directory SSIS 数据源即使您对 SSIS 不感兴趣,对于源对象的 LDAP 查询和用于组成员身份的 C# 也可能对查看此问题的任何人都很方便。