summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-02-24 13:21:18 +0000
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-02-24 13:21:18 +0000
commitec88785a50e045fced5ed7f86efd0c6e91fc7c61 (patch)
tree5df0069753fcb4f3a7af2af83af1072add7dd4cd
parentbab75f963d922fdbac6b86290f29312d74763c09 (diff)
downloadpykolab-ec88785a50e045fced5ed7f86efd0c6e91fc7c61.tar.gz
Mandatorily add uid to the list of authentication attributes to search for
Start on sync_repl support
-rw-r--r--pykolab/auth/ldap/__init__.py46
1 files changed, 45 insertions, 1 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index c0cd60a..c52bd55 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -254,6 +254,9 @@ class LDAP(object):
else:
auth_search_attrs = [ 'uid', 'mail' ]
+ if not 'uid' in auth_search_attrs:
+ auth_search_attrs.append('uid')
+
auth_search_filter = [ '(|' ]
for auth_search_attr in auth_search_attrs:
@@ -542,6 +545,41 @@ class LDAP(object):
):
pass
+ def _sync_repl(self,
+ base_dn,
+ scope=ldap.SCOPE_SUBTREE,
+ filterstr="(objectClass=*)",
+ attrlist=None,
+ attrsonly=0,
+ timeout=-1,
+ callback=False,
+ primary_domain=None,
+ secondary_domains=[]
+ ):
+
+ import syncrepl
+
+ ldap_sync_conn = syncrepl.DNSync(
+ '/var/lib/pykolab/syncrepl.db',
+ ldap_url.initializeUrl(),
+ trace_level=ldapmodule_trace_level,
+ trace_file=ldapmodule_trace_file
+ )
+
+ msgid = ldap_sync_conn.syncrepl_search(
+ base_dn,
+ scope,
+ mode='refreshAndPersist',
+ filterstr=filterstr
+ )
+
+ try:
+ # Here's where returns need to be taken into account...
+ while ldap_sync_conn.syncrepl_poll(all=1, msgid=msgid):
+ pass
+ except KeyboardInterrupt:
+ pass
+
def _regular_search(self,
base_dn,
scope=ldap.SCOPE_SUBTREE,
@@ -947,7 +985,13 @@ class LDAP(object):
quiet=True
)
- self.ldap.simple_bind_s(bind_dn, bind_pw)
+ try:
+ self.ldap.simple_bind_s(bind_dn, bind_pw)
+ except ldap.SERVER_DOWN, e:
+ error = eval("%s" %(e))
+ log.error(_("Error binding to LDAP: %s") %(error['desc']))
+ # TODO: Exit the fork (if fork!)
+ return
# TODO: The quota and alternative address attributes are actually
# supposed to be settings.