国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > SQL Server > 正文

SQLServer 使用ADSI執(zhí)行分布式查詢ActiveDorectory對象

2024-08-31 00:58:47
字體:
供稿:網(wǎng)友
Step 1:Creating a Linked Server.
EXEC sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5', 'ADSDSOObject', 'adsdatasource'
Step 2:Creating a SQL Server Authenticated Login
EXEC sp_addlinkedsrvlogin @rmtsrvname = N'ADSI', @locallogin = NULL , @useself = N'False', @rmtuser = N'domain/Account', @rmtpassword = N'Password'
對于 SQL Server 授權(quán)登錄,可以使用sp_addlinkedsrvlogin 系統(tǒng)存儲過程配置用于連接到目錄服務(wù)的適當(dāng)?shù)牡卿?密碼.
參考這里:
如果SQLServer使用Windows 授權(quán)登錄,只需自映射就足以通過使用 SQL Server 安全委托來訪問AD。簡單點(diǎn)說就是直接運(yùn)行第三步語句即可.
Step 3:Querying the Directory Service.

復(fù)制代碼 代碼如下:


-- 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''')


引用:



說明:但是這樣默認(rèn)查詢出來的是1000個對象.怎么辦呢?
方法一,通過字母來循環(huán).見以下:

復(fù)制代碼 代碼如下:


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


以上方法源自于:

我推薦的方法:在微軟搜索到的.如何通過 NTDSUtil為服務(wù)器修改限制 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.

This setting changes if you add another processor to your server.

3.

You can use the Show Values command to verify your changes.

To save the changes, use Commit 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.

資料來源:

?scid=kb%3Bzh-cn%3B299410&x=16&y=10

如何使用SQL查詢活動目錄對象語法:

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 阜阳市| 涿鹿县| 宜州市| 保山市| 南华县| 元阳县| 黔西县| 扬中市| 襄汾县| 连州市| 延庆县| 鄯善县| 金寨县| 沙洋县| 长沙市| 丘北县| 双辽市| 黔西| 通州区| 敦煌市| 松滋市| 惠安县| 衡水市| 西城区| 鄢陵县| 盐山县| 句容市| 济南市| 翁源县| 柳河县| 开鲁县| 柯坪县| 丁青县| 年辖:市辖区| 灵丘县| 灵石县| 得荣县| 涿州市| 遵义市| 白沙| 兴隆县|