Created
March 21, 2016 11:25
-
-
Save syshack/098056a63c95d0a58e1b to your computer and use it in GitHub Desktop.
chanegadpasswd.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding=utf-8 | |
import ldap | |
server = 'ldaps://ad.xxx.com' | |
l = ldap.initialize(server,trace_level=2) | |
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER) | |
dn = "[email protected]" | |
pw = "xxxxxxxxxx" | |
l.bind_s(dn,pw) | |
newdn = 'CN=syshack,CN=Users,DC=xxx,DC=com' | |
mod_attrs = [(ldap.MOD_REPLACE,'unicodePwd',''.join(('"', "xxxxxxxxxxxxxx", '"')).encode('utf-16').lstrip('\377\376'))] | |
l.modify_s(newdn, mod_attrs) | |
l.unbind_s() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment