server/ldaputils.py
changeset 8430 5bee87a14bb1
parent 8387 b59af20a868d
child 8473 2646a8e99b0d
equal deleted inserted replaced
8429:cad2d8e03b33 8430:5bee87a14bb1
   223         return eid
   223         return eid
   224 
   224 
   225     def object_exists_in_ldap(self, dn):
   225     def object_exists_in_ldap(self, dn):
   226         cnx = self.get_connection().cnx #session.cnxset.connection(self.uri).cnx
   226         cnx = self.get_connection().cnx #session.cnxset.connection(self.uri).cnx
   227         if cnx is None:
   227         if cnx is None:
   228             return True # ldap unreachable, suppose it exists
   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
   229         try:
   230         try:
   230             cnx.search_s(dn, self.user_base_scope)
   231             cnx.search_s(dn, self.user_base_scope)
   231         except ldap.PARTIAL_RESULTS:
   232         except ldap.PARTIAL_RESULTS:
   232             pass
   233             self.warning('PARTIAL RESULTS for dn %s', dn)
   233         except ldap.NO_SUCH_OBJECT:
   234         except ldap.NO_SUCH_OBJECT:
   234             return False
   235             return False
   235         return True
   236         return True
   236 
   237 
   237     def _connect(self, user=None, userpwd=None):
   238     def _connect(self, user=None, userpwd=None):