最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2010年05月23日 01:35:17   作者:  
SQLServer 通過使用 ADSI 執(zhí)行分布式查詢ActiveDorectory對象的實現(xiàn)方法。
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 授權登錄,可以使用sp_addlinkedsrvlogin 系統(tǒng)存儲過程配置用于連接到目錄服務的適當?shù)牡卿?密碼.
參考這里: http://blogs.msdn.com/euanga/archive/2007/03/22/faq-how-do-i-query-active-directory-from-sql-server.aspx
如果SQLServer使用Windows 授權登錄,只需自映射就足以通過使用 SQL Server 安全委托來訪問AD。簡單點說就是直接運行第三步語句即可.
Step 3:Querying the Directory Service.
復制代碼 代碼如下:

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

引用:
http://msdn2.microsoft.com/en-us/library/aa772380.aspx
http://www.atlantamdf.com/presentations/AtlantaMDF_111201_examples.txt

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

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.

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.

資料來源:

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

相關文章

最新評論

凤阳县| 柏乡县| 浦县| 金坛市| 祁连县| 五常市| 江源县| 濮阳县| 新龙县| 邹城市| 色达县| 郧西县| 铅山县| 凉城县| 都昌县| 郎溪县| 南康市| 阿拉尔市| 石景山区| 盖州市| 饶河县| 沁源县| 库尔勒市| 板桥市| 蒙山县| 缙云县| 紫云| 麻栗坡县| 巢湖市| 台江县| 崇仁县| 黔西| 宁津县| 紫云| 桓台县| 湟中县| 莱西市| 叙永县| 泗阳县| 沐川县| 山东|