diff options
author | 2011-07-21 04:26:19 +0300 | |
---|---|---|
committer | 2011-07-21 04:26:19 +0300 | |
commit | 11c7118dd9ff16eb138391d920b1e47e0493a176 (patch) | |
tree | 465c46a481a6db7d6953d13d8bee9aae3a3f769b | |
parent | Add custon widget/field that will print multivalue LDAP attributes as (diff) | |
download | identity.gentoo.org-11c7118dd9ff16eb138391d920b1e47e0493a176.tar.gz identity.gentoo.org-11c7118dd9ff16eb138391d920b1e47e0493a176.tar.bz2 identity.gentoo.org-11c7118dd9ff16eb138391d920b1e47e0493a176.zip |
New lib to cleanup the secondary password from the LDAP server
-rw-r--r-- | libraries/ldap_cleanup.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libraries/ldap_cleanup.py b/libraries/ldap_cleanup.py new file mode 100644 index 0000000..92dd450 --- /dev/null +++ b/libraries/ldap_cleanup.py @@ -0,0 +1,17 @@ +#from proj_root import * +import os +import sys +import ldap +from okupy.libraries.encryption import sha_password +from okupy.libraries.ldap_wrappers import * +from django.conf import settings +#sys.path.append(PROJECT_ROOT) +#os.environ['DJANGO_SETTINGS_MODULE'] = 'okupy.settings' + +def ldap_second_passwd_cleanup(request, hash, l): + base_dn = settings.LDAP_BASE_ATTR + '=' + request.user.username + request.user.get_profile().base_dn + mod_attrs = [(ldap.MOD_DELETE, 'userPassword', hash)] + try: + l.modify_s(base_dn, mod_attrs) + except Exception as error: + logger.error(error, extra = log_extra_data(request)) |