Get activedirectory from samba4



I使用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信息?

这些行:

Set RootDSE = GetObject("LDAP://RootDSE")
Base = "<LDAP://" & RootDSE.Get("defaultNamingContext") & ">"

告诉它连接到当前计算机加入的域,并获取域的可分辨名称。但只有当计算机加入到您想要的域时,这才有效。

如果你想连接到任何其他域控制器,那么你可以在LDAP://路径中指定域名:

Base = "<LDAP://example.com>"

或者一个IP,如果这就是你所拥有的:

Base = "<LDAP://10.0.0.1>"

Samba是一款免费的开源软件,它提供了Windows操作系统Linux/Unix操作系统之间的标准互操作性。

您可以参考设置Samba4 Active Directory域控制器的此链接,该链接涵盖UbuntuCentOSWindows以下主题:

注意:从4.0版本开始,Samba可以作为Active Directory(AD(域控制器(DC(运行。如果您在中安装Samba在生产环境中,建议运行两个或多个DC故障切换原因。

最新更新