这篇文章主要为大家详细介绍了SQL Server 使用ADSI执行分布式查询ActiveDorectory对象,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随四海网的小编两巴掌来看看吧!
Step 1:Creating a Linked Server.代码如下:
-- Query for a list of User entries in an OU using the SQL query dialect
select convert(varchar(50), [Name]) as FullName,
convert(varchar(50), Title) as Title,
convert(varchar(50), TelephoneNumber) as PhoneNumber
from openquery(ADSI,
'select Name, Title, TelephoneNumber
from ''LDAP://OU=Directors,OU=Atlanta,OU=Intellinet,DC=vizability,DC=intellinet,DC=com''
where objectClass = ''User''')
-- Query for a list of Group entries in an OU using the SQL query dialect
select convert(varchar(50), [Name]) as GroupName,
convert(varchar(50), [Description]) GroupDescription
from openquery(ADSI,
'select Name, Description
from ''LDAP://OU=VizAbility Groups,DC=vizability,DC=intellinet,DC=com''
where objectClass = ''Group''')
代码如下:
CREATE TABLE #tmpADUsers
( employeeId varchar(10) NULL,
SAMAccountName varchar(255) NOT NULL,
email varchar(255) NULL)
GO
/**//* AD is limited to send 1000 records in one batch. In an ADO interface you can define this batch size, not in OPENQUERY.
Because of this limitation, we just loop through the alphabet.
*/
DECLARE @cmdstr varchar(255)
DECLARE @nAsciiValue smallint
DECLARE @sChar char(1)
SELECT @nAsciiValue = 65
WHILE @nAsciiValue < 91
BEGIN
SELECT @sChar= CHAR(@nAsciiValue)
EXEC master..xp_sprintf @cmdstr OUTPUT, 'SELECT employeeId, SAMAccountName, Mail FROM OPENQUERY( ADSI, ''SELECT Mail, SAMAccountName, employeeID FROM ''''LDAP://dc=central,dc=mydomain,dc=int''''WHERE objectCategory = ''''Person'''' AND SAMAccountName = ''''%s*'''''' )', @sChar
INSERT #tmpADUsers
EXEC( @cmdstr )
SELECT @nAsciiValue = @nAsciiValue + 1
END
DROP TABLE #tmpADUsers
以上方法源自于:http://www.sqlservercentral.com/Forums/Topic231658-54-1.aspx#bm231954
我推荐的方法:在微软搜索到的.如何通过 NTDSUtil为服务器修改限制 maxPageSize
1. |
Click Start, and then click Run. |
2. |
In the Open text box, type ntdsutil, and then press ENTER. To view help at any time, type ? at the command prompt. |
Modifying policy settings
1. |
At the Ntdsutil.exe command prompt, type LDAP policies, and then press ENTER. |
2. |
At the LDAP policy command prompt, type Set setting to variable, and then press ENTER. For example, type Set MaxPoolThreads to 8. |
3. |
You can use the Show Values command to verify your changes. |
4. |
When you finish, type q, and then press ENTER. |
5. |
To quit Ntdsutil.exe, at the command prompt, type q, and then press ENTER. |
资料来源:
http://support.microsoft.com/kb/315071/en-us
http://support.microsoft.com/?scid=kb%3Bzh-cn%3B299410&x=16&y=10
如何使用SQL查询活动目录对象语法: http://www.microsoft.com/china/technet/community/columns/scripts/sg0505.mspx#EMBAC
本文来自:http://www.q1010.com/179/7427-0.html
注:关于SQL Server 使用ADSI执行分布式查询ActiveDorectory对象的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:SQL SERVER
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。