server/ldaputils.py
branchstable
changeset 8638 9f95c2368b8b
parent 8586 bc74608d2003
child 8674 001c1592060a
child 8680 2bb3021f4ffe
equal deleted inserted replaced
8636:c491f945f878 8638:9f95c2368b8b
   219         eid = self.repo.extid2eid(self, user['dn'], 'CWUser', session, {})
   219         eid = self.repo.extid2eid(self, user['dn'], 'CWUser', session, {})
   220         if eid < 0:
   220         if eid < 0:
   221             # user has been moved away from this source
   221             # user has been moved away from this source
   222             raise AuthenticationError()
   222             raise AuthenticationError()
   223         return eid
   223         return eid
   224 
       
   225     def object_exists_in_ldap(self, dn):
       
   226         cnx = self.get_connection().cnx #session.cnxset.connection(self.uri).cnx
       
   227         if cnx is None:
       
   228             self.warning('Could not establish connexion with LDAP server, assuming dn %s exists', dn)
       
   229             return True # ldap unreachable, let's not touch it
       
   230         try:
       
   231             cnx.search_s(dn, self.user_base_scope)
       
   232         except ldap.PARTIAL_RESULTS:
       
   233             self.warning('PARTIAL RESULTS for dn %s', dn)
       
   234         except ldap.NO_SUCH_OBJECT:
       
   235             return False
       
   236         return True
       
   237 
   224 
   238     def _connect(self, user=None, userpwd=None):
   225     def _connect(self, user=None, userpwd=None):
   239         protocol, hostport = self.connection_info()
   226         protocol, hostport = self.connection_info()
   240         self.info('connecting %s://%s as %s', protocol, hostport,
   227         self.info('connecting %s://%s as %s', protocol, hostport,
   241                   user and user['dn'] or 'anonymous')
   228                   user and user['dn'] or 'anonymous')