<tfoot id='Njkik'></tfoot>
    • <bdo id='Njkik'></bdo><ul id='Njkik'></ul>

  1. <legend id='Njkik'><style id='Njkik'><dir id='Njkik'><q id='Njkik'></q></dir></style></legend>
    <i id='Njkik'><tr id='Njkik'><dt id='Njkik'><q id='Njkik'><span id='Njkik'><b id='Njkik'><form id='Njkik'><ins id='Njkik'></ins><ul id='Njkik'></ul><sub id='Njkik'></sub></form><legend id='Njkik'></legend><bdo id='Njkik'><pre id='Njkik'><center id='Njkik'></center></pre></bdo></b><th id='Njkik'></th></span></q></dt></tr></i><div id='Njkik'><tfoot id='Njkik'></tfoot><dl id='Njkik'><fieldset id='Njkik'></fieldset></dl></div>

      <small id='Njkik'></small><noframes id='Njkik'>

    1. 使用 Python ldap 模块以编程方式启用/禁用帐户?

      时间:2023-07-24
      • <small id='DbNwt'></small><noframes id='DbNwt'>

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

            • <bdo id='DbNwt'></bdo><ul id='DbNwt'></ul>
                <legend id='DbNwt'><style id='DbNwt'><dir id='DbNwt'><q id='DbNwt'></q></dir></style></legend>
                  <tbody id='DbNwt'></tbody>
                本文介绍了使用 Python ldap 模块以编程方式启用/禁用帐户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想以编程方式启用/禁用 LDAP 用户帐户.从命令提示符我可以使用 dsutil ,这显然设置/删除 nsAccountLock 操作属性.我试图做 modify_s() 以在 Python 中设置和删除此属性,但始终收到以下错误消息:对条目 '' 的 'nsAccountLock' 属性的'写入'权限不足".

                I would like to programmatically enable/disable LDAP user accounts. From the command prompt I can use dsutil and this apparently sets/removes the nsAccountLock operational attribute. I have attempted to do modify_s() to set and remove this attribute from w/in Python but always get the following error message: "Insufficient 'write' privilege to the 'nsAccountLock' attribute of entry ''".

                有没有办法通过 Python 以编程方式设置/删除/添加操作属性或启用/禁用 ldap 用户?

                Is there a way to set/remove/add operational attributes or otherwise enable/disable ldap users programmatically through Python?

                谢谢,C

                推荐答案

                您应该使用包含一组控制位的属性userAccountControl".

                You should use the attribute 'userAccountControl' which contains a set of control bits.

                如果你是管理普通用户,启用用户:

                If you are managing normal users, to enable user:

                userAccountControl = 512
                

                并禁用它:

                userAccountControl = 514
                

                一般来说,如果您想启用/禁用现有用户,您应该检索当前值并以这种方式更新它.

                Generally, if you want to enable/disable an existing user, you should retrieve current value and update it this way.

                userADAccountControlFlag = 2
                userAccountControl = user.userAccountControl
                
                # To enable user:
                userAccountControl = userAccountControl & ~userADAccountControlFlag # (& bit-wise AND, ~ bit-wise Negate)
                
                # To disable user:
                userAccountControl = userAccountControl | userADAccountControlFlag # (| bit-wise OR)
                
                user.userAccountControl = userAccountControl
                
                # Then update user on ldap server
                

                您可以在此处找到有关 userAccountControl 属性的更多信息:http://www.selfadsi.org/ads-attributes/user-userAccountControl.htm

                you can find more about userAccountControl attribute here: http://www.selfadsi.org/ads-attributes/user-userAccountControl.htm

                这篇关于使用 Python ldap 模块以编程方式启用/禁用帐户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:使用 Django Auth Ldap 将 LDAP 用户映射到 Django 用户 下一篇:Python 3 有 LDAP 模块吗?

                相关文章

                <tfoot id='xREI1'></tfoot>
              1. <small id='xREI1'></small><noframes id='xREI1'>

                • <bdo id='xREI1'></bdo><ul id='xREI1'></ul>
                <legend id='xREI1'><style id='xREI1'><dir id='xREI1'><q id='xREI1'></q></dir></style></legend>

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