开发者

unlocking Locked user accounts on Active Directory using Python ldap module

开发者 https://www.devze.com 2023-04-02 09:46 出处:网络
I recently implemented password reset on AD using python ldap module. This involved passing modified attributes in this manner:

I recently implemented password reset on AD using python ldap module.

This involved passing modified attributes in this manner:

add_pass = [(ldap.MOD_REPLACE, "unicodePwd", )]

This worked since the passwords on AD are stored in attribute "unicodePwd".

开发者_开发知识库

Now I want to unlock a locked user account but I cannot find the attribute that must be changed to achieve the same.

Could you guys please tell me which attribute I have to change?


To unlock a user, you need to set the lockoutTime attribute to 0.


Have a look to userAccountControl attribute ADS_UF_ACCOUNTDISABLE flag which allow tu unable a disabled account.

----EDITED------

@Brrian Desmond is true to unlock a user, you need to set the lockoutTime attribute to 0.


def unlock_account_ad(message):
    c.bind()
    unlock_account = c.extend.microsoft.unlock_account(user='cn=' + message + ', 
                                                 ou=%OU%, dc=%domain%, dc=%DC%')
    c.unbind()
0

精彩评论

暂无评论...
验证码 换一张
取 消