Ejemplo n.º 1
0
 def exists(self):
     '''Does this object exist in the LDAP tree?'''
     try:
         lc.search(self.get_dn(), ldap.SCOPE_BASE, None, [])
         return True
     except ldap.NO_SUCH_OBJECT:
         return False
Ejemplo n.º 2
0
 def exists(self):
     '''Does this object exist in the LDAP tree?'''
     try:
         lc.search(self.get_dn(), ldap.SCOPE_BASE, None, [])
         return True
     except ldap.NO_SUCH_OBJECT:
         return False
Ejemplo n.º 3
0
 def check_all(cls):
     '''Perform consistency checks. Each LDAP class may define a method check().
     When this method is run, all of the check() methods appropriate to each object
     in the tree are run. If any "assert"s fail, a detailed error message is given'''
     try:
         lc.search(cls.cls_dn_str, ldap.SCOPE_BASE, None, [])
     except Exception,e:
         lerr("LDAP object of class %s does not exist: %s" % (cls, e))
Ejemplo n.º 4
0
 def check_all(cls):
     '''Perform consistency checks. Each LDAP class
        may define a method check(). When this method
        is run, all of the check() methods appropriate
        to each object in the tree are run. If any
        "assert"s fail, a detailed error message is given'''
     try:
         lc.search(cls.cls_dn_str, ldap.SCOPE_BASE, None, [])
     except Exception, e:
         lerr("LDAP object of class %s does not exist: %s" % (cls, e))
Ejemplo n.º 5
0
 def results():
     for (dn, _) in lc.search(cls.cls_dn_str,
                              ldap.SCOPE_SUBTREE, filter.filterstr, []):
         if dn_to_tuple(dn) not in LDAPClass._classmap:
             subcls = LDAPClass.get_class_by_dn(dn)
             assert(issubclass(subcls, cls))
             yield subcls(obj_dn=dn)
Ejemplo n.º 6
0
 def results():
     for (dn, _) in lc.search(cls.cls_dn_str, ldap.SCOPE_SUBTREE,
                              filter.filterstr, []):
         if dn_to_tuple(dn) not in LDAPClass._classmap:
             subcls = LDAPClass.get_class_by_dn(dn)
             assert (issubclass(subcls, cls))
             yield subcls(obj_dn=dn)
Ejemplo n.º 7
0
    def __init__(self, id=None, obj_dn=None):
        '''Construct an object, given either obj_dn (the string DN of the object)
        or id (a value for the RDN of the object)'''
        if obj_dn is None:
            obj_dn = tuple_to_dn(((type(self).rdn_attr, id),) + self.cls_dn_tuple)
        self._dn = obj_dn

	try:
            # If the case of the dn is wrong, some methods will fail
            # This will fix it.
            self._dn = lc.search(obj_dn, 0, None, ['dn'])[0][0]
	except:
            # This object is "no such object"
            pass
Ejemplo n.º 8
0
    def __init__(self, id=None, obj_dn=None):
        '''Construct an object, given either obj_dn
        (the string DN of the object) or id
        (a value for the RDN of the object)'''
        if obj_dn is None:
            obj_dn = tuple_to_dn(((type(self).rdn_attr, id), ) +
                                 self.cls_dn_tuple)
        self._dn = obj_dn

        try:
            # If the case of the dn is wrong, some methods will fail
            # This will fix it.
            self._dn = lc.search(obj_dn, 0, None, ['dn'])[0][0]
        except:
            # This object is "no such object"
            pass
Ejemplo n.º 9
0
 def _raw_readattrs(self, attrlist):
     res = lc.search(self.get_dn(), ldap.SCOPE_BASE, None, attrlist)[0][1]
     for a in attrlist:
         if a not in res:
             res[a] = []
     return res
Ejemplo n.º 10
0
 def _raw_readattrs(self, attrlist):
     res = lc.search(self.get_dn(), ldap.SCOPE_BASE, None, attrlist)[0][1]
     for a in attrlist:
         if a not in res:
             res[a] = []
     return res