gpt4 book ai didi

asp-classic - 使用 VBScript 查询 Active Directory

转载 作者:行者123 更新时间:2023-12-05 00:08:52 25 4
gpt4 key购买 nike

我要查询Active Directory使用 VBScript(经典 ASP)。
我怎样才能做到这一点?

最佳答案

要查看 OU 的所有成员,请尝试以下操作...

Set objOU = GetObject("LDAP://OU=YourOU,DC=YourDomain,DC=com")
For each objMember in ObjOU ' get all the members'

' do something'

Next

要对 DN 进行自定义搜索,请尝试此操作...
set conn = createobject("ADODB.Connection")
Set iAdRootDSE = GetObject("LDAP://RootDSE")
strDefaultNamingContext = iAdRootDSE.Get("defaultNamingContext")
Conn.Provider = "ADsDSOObject"
Conn.Open "ADs Provider"

strQueryDL = "<LDAP://" & strDefaultNamingContext & ">;(&(objectCategory=person)(objectClass=user));distinguishedName,adspath;subtree"
set objCmd = createobject("ADODB.Command")
objCmd.ActiveConnection = Conn
objCmd.Properties("SearchScope") = 2 ' we want to search everything
objCmd.Properties("Page Size") = 500 ' and we want our records in lots of 500

objCmd.CommandText = strQueryDL
Set objRs = objCmd.Execute

While Not objRS.eof

' do something with objRS.Fields("distinguishedName")'
objRS.MoveNext
Wend

关于asp-classic - 使用 VBScript 查询 Active Directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1090336/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com