diff options
author | Marian Sigler <m@qjym.de> | 2012-09-13 21:46:47 +0200 |
---|---|---|
committer | Marian Sigler <m@qjym.de> | 2012-09-13 21:46:47 +0200 |
commit | f754e184db19f1c3d2e3031e67b6ed263067c76a (patch) | |
tree | f6912290c292a46cb916c37af01270a5b1fc23df /account.py | |
parent | 671adf62fa8d4b6db75fbfd1be1af7deec13f80c (diff) | |
download | web-f754e184db19f1c3d2e3031e67b6ed263067c76a.tar.gz web-f754e184db19f1c3d2e3031e67b6ed263067c76a.tar.bz2 web-f754e184db19f1c3d2e3031e67b6ed263067c76a.zip |
first pieces of code
Diffstat (limited to 'account.py')
-rw-r--r-- | account.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/account.py b/account.py new file mode 100644 index 0000000..1c764a5 --- /dev/null +++ b/account.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +import ldap +import sys + +LDAP_HOST = 'localhost' +LDAP_BASE_DN = 'dc=nodomain' +USER = 'cn=admin' +PASS = 'blubb' + + +class Account(object): + def __init__(self, ldap_host, base_dn, user, password): + self.con = ldap.open(ldap_host) + self.con.simple_bind(user, password) + self.base_dn = base_dn + + + def list(self, *args, **kwargs): + entries = self.con.search_s(self.base_dn, ldap.SCOPE_SUBTREE, *args, **kwargs) + + for entry in entries: + print(entry) + + + def register(self, name, attr): + dn = 'cn=%s,%s' % (name, self.base_dn) + name = self.con.add_s(dn, attr) + print('Added ' % name) + + + def modify(self, name, attr): + dn = 'cn=%s,%s' % (name, self.base_dn) + name = self.con.modify_s(dn, attr) + print('Modify ' % name) + + + def delete(self, name): + dn = 'cn=%s,%s' % (name, self.base_dn) + name = self.con.delete_s(dn, attr) + print('Delete ' % name) + + +a = Account(LDAP_HOST, LDAP_BASE_DN, USER, PASS) + +class _Missing(object): + pass +_missing = _Missing() |