【问题标题】:Get activedirectory from samba4从 samba4 获取活动目录
【发布时间】: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 信息?

【问题讨论】:

标签: excel vba active-directory samba


【解决方案1】:

这些行:

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

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

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

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

或者一个 IP,如果你只有这些的话:

Base = "<LDAP://10.0.0.1>"

【讨论】:

  • 那就不要使用 RootDSE。直接连接到 LDAP://10.1.1.5
  • 我试过不行
  • @DmitrijHolkin 您尝试使用Base = "&lt;LDAP://10.1.1.5&gt;"?错误信息是什么?
  • 同样的错误 imgur.com/218O3z4
  • @DmitrijHolkin 那听起来像是网络问题。打开一个 PowerShell 窗口并尝试 Test-NetConnection 10.1.1.5 -Port 389 - 如果失败,那么您需要先弄清楚。
【解决方案2】:

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

您可以参考link 了解设置 Samba4 Active Directory 域控制器,其中涵盖了 UbuntuCentOSWindows

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-30
    相关资源
    最近更新 更多