• <tfoot id='iPDSR'></tfoot>
      <bdo id='iPDSR'></bdo><ul id='iPDSR'></ul>
    1. <small id='iPDSR'></small><noframes id='iPDSR'>

        <legend id='iPDSR'><style id='iPDSR'><dir id='iPDSR'><q id='iPDSR'></q></dir></style></legend>
      1. <i id='iPDSR'><tr id='iPDSR'><dt id='iPDSR'><q id='iPDSR'><span id='iPDSR'><b id='iPDSR'><form id='iPDSR'><ins id='iPDSR'></ins><ul id='iPDSR'></ul><sub id='iPDSR'></sub></form><legend id='iPDSR'></legend><bdo id='iPDSR'><pre id='iPDSR'><center id='iPDSR'></center></pre></bdo></b><th id='iPDSR'></th></span></q></dt></tr></i><div id='iPDSR'><tfoot id='iPDSR'></tfoot><dl id='iPDSR'><fieldset id='iPDSR'></fieldset></dl></div>
      2. ldap3 python 搜索组成员并检索他们的 sAMAcountName (Active Directory)

        ldap3 python search members of a group and retrieve their sAMAcountName (Active Directory)(ldap3 python 搜索组成员并检索他们的 sAMAcountName (Active Directory))
      3. <legend id='letXo'><style id='letXo'><dir id='letXo'><q id='letXo'></q></dir></style></legend>
          <bdo id='letXo'></bdo><ul id='letXo'></ul>

          • <tfoot id='letXo'></tfoot>
            • <i id='letXo'><tr id='letXo'><dt id='letXo'><q id='letXo'><span id='letXo'><b id='letXo'><form id='letXo'><ins id='letXo'></ins><ul id='letXo'></ul><sub id='letXo'></sub></form><legend id='letXo'></legend><bdo id='letXo'><pre id='letXo'><center id='letXo'></center></pre></bdo></b><th id='letXo'></th></span></q></dt></tr></i><div id='letXo'><tfoot id='letXo'></tfoot><dl id='letXo'><fieldset id='letXo'></fieldset></dl></div>
                <tbody id='letXo'></tbody>

                1. <small id='letXo'></small><noframes id='letXo'>

                  本文介绍了ldap3 python 搜索组成员并检索他们的 sAMAcountName (Active Directory)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将 ldap3 与 python 一起使用来检索组的成员并检索他们的 sAMAccountName,因为我们混合了 DN(一些带有 NTID,其他带有名字/姓氏).

                  I'm trying to use ldap3 with python to retrieve members of a group and also retrieve their sAMAccountName as we have mixed DN's (some with NTID and others with first/last name).

                  我一直在尝试这个没有 0 运气,任何帮助将不胜感激:

                  I've been trying this with no 0 luck, any help would be appreciated:

                  from ldap3 import Server, Connection, AUTO_BIND_NO_TLS, SUBTREE, BASE,
                        ALL_ATTRIBUTES, ObjectDef, AttrDef, Reader, Entry, Attribute,
                        OperationalAttribute import ldap3
                  
                  conn = Connection(Server('adserver.com', port=389, use_ssl=False),
                                    auto_bind=AUTO_BIND_NO_TLS, user='DOMAIN\NTID',
                                    password='somepassword')
                  
                  conn.search(search_base='CN=GROUPNAME,OU=Groups,OU=Resources,OU=Global,DC=adserver.com',
                              search_filter='(objectCategory=person)', search_scope=SUBTREE,
                              attributes = ['sAMAAccountName'], size_limit=0) 
                  
                  print(conn.response_to_json())
                  

                  推荐答案

                  在搜索成员之前,您必须先从组本身中下拉成员列表.

                  Before you can search the members you must first pull down the list of members from the group itself.

                  conn.search(
                      search_base='CN=GROUPNAME,OU=Groups,OU=Resources,OU=Global,DC=adserver.com',
                      search_filter='(objectClass=group)',
                      search_scope='SUBTREE',
                      attributes = ['member']
                  )
                  
                  for entry in conn.entries:
                      print(entry.member.values)
                  

                  这将打印出成员列表作为专有名称.

                  This will print out a list of members as distinguished names.

                  然后您需要执行一个新的搜索,遍历每个成员并返回每个成员的 sAMAccountName.

                  You will then need to perform a new search that iterates through each of the members and returns the sAMAccountName for each member.

                  下面是完整代码的样子(可能需要调整):

                  Here is what the full code might look like (may need to be tweaked):

                  conn.search(
                      search_base='CN=GROUPNAME,OU=Groups,OU=Resources,OU=Global,DC=adserver.com',
                      search_filter='(objectClass=group)',
                      search_scope='SUBTREE',
                      attributes = ['member']
                  )
                  
                  for entry in conn.entries:
                      for member in entry.member.values:
                          conn.search(
                              search_base='OU=Global,DC=adserver.com',
                              search_filter=f'(distinguishedName={member})',
                              attributes=[
                                  'sAMAccountName'
                              ]
                          )
                  
                          user_sAMAccountName = conn.entries[0].sAMAccountName.values
                  
                          print(user_sAMAccountName)
                  

                  这篇关于ldap3 python 搜索组成员并检索他们的 sAMAcountName (Active Directory)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pythonic and efficient way of finding adjacent cells in grid(在网格中查找相邻单元格的 Pythonic 和有效方法)
                  map a hexagonal grid in matplotlib(在 matplotlib 中映射六边形网格)
                  Execute arbitrary python code remotely - can it be done?(远程执行任意 python 代码 - 可以吗?)
                  Python - Plotting colored grid based on values(Python - 根据值绘制彩色网格)
                  Is there a GUI design app for the Tkinter / grid geometry?(是否有 Tkinter/网格几何图形的 GUI 设计应用程序?)
                  tkinter Canvas Scrollbar with Grid?(带有网格的 tkinter 画布滚动条?)
                    <tbody id='4yMGe'></tbody>
                  • <bdo id='4yMGe'></bdo><ul id='4yMGe'></ul>

                      • <i id='4yMGe'><tr id='4yMGe'><dt id='4yMGe'><q id='4yMGe'><span id='4yMGe'><b id='4yMGe'><form id='4yMGe'><ins id='4yMGe'></ins><ul id='4yMGe'></ul><sub id='4yMGe'></sub></form><legend id='4yMGe'></legend><bdo id='4yMGe'><pre id='4yMGe'><center id='4yMGe'></center></pre></bdo></b><th id='4yMGe'></th></span></q></dt></tr></i><div id='4yMGe'><tfoot id='4yMGe'></tfoot><dl id='4yMGe'><fieldset id='4yMGe'></fieldset></dl></div>
                      • <small id='4yMGe'></small><noframes id='4yMGe'>

                        <tfoot id='4yMGe'></tfoot><legend id='4yMGe'><style id='4yMGe'><dir id='4yMGe'><q id='4yMGe'></q></dir></style></legend>