【发布时间】:2022-01-26 07:08:16
【问题描述】:
我使用 LDAP 脚本获取 AD 信息
Function getAD()
UserName = Environ("USERNAME")
Set RootDSE = GetObject("LDAP://RootDSE")
Base = "<LDAP://" & RootDSE.Get("defaultNamingContext") & ">"
'filter on user objects with the given account name
fltr = "(&(objectClass=user)(objectCategory=person)" & "(sAMAccountName=" & UserName & "))"
'add other attributes according to your requirements
attr = "account"
scope = "subtree"
Set conn = CreateObject("ADODB.Connection")
conn.Provider = "ADsDSOObject"
conn.Open "Active Directory Provider"
Set cmd = CreateObject("ADODB.Command")
Set cmd.activeconnection = conn
cmd.CommandText = Base & ";" & fltr & ";" & attr & ";" & scope
Set rs = cmd.Execute
Do Until rs.EOF
' getAD = rs.Fields("distinguishedName").Value
rs.movenext
Loop
rs.Close
conn.Close
End Function
但是如何从 samba4 域控制器获取 AD 信息?
【问题讨论】:
-
请查看此链接,它可能对您有所帮助:wiki.samba.org/index.php/…
标签: excel vba active-directory samba