日期:2014-05-18  浏览次数:20947 次

sql访问怎么检索ActiveDirectory中的数据
rt
谢啦

------解决方案--------------------
string path = "LDAP://DC=Domain,DC=eg"; 
DirectoryEntry entry = new DirectoryEntry(path, user, password); 
SearchResult sResultSet = null; 
DirectorySearcher directorySearch = new DirectorySearcher(entry); 
directorySearch.SearchScope = SearchScope.Subtree; 
directorySearch.Filter = string.Format("(&(samAccountName={0})(memberof:1.2.840.113556.1.4.1941:=CN=Application A Group,OU=Application Groups,DC=Domain,DC=eg))", lookUpUser); 
searchResultSet = dSearch.FindOne();

------解决方案--------------------

EXEC dbo.sp_addlinkedserver @server = N'ADSI',@srvproduct=N'Active Directory Services', @provider=N'ADsDSOObject', @datasrc=N'FullDomain(如:corp.microsoft.com)' --连接数据库

EXEC sp_addlinkedsrvlogin 'ADSI', 'true'


select * from openquery
(ADSI,'SELECT * FROM ''LDAP://FullDomain''')