def createLdiff(self):
     session = self.pg.getProprioSession()
     ldifs = []
     for proprietaire in self.getProprietaires(session):
         ldapProprio = registry.queryAdapter(proprietaire,
                                             ILDAPProprietaire)
         ldifs.append(ldapProprio.ldif())
     session.flush()
     return "\n".join(ldifs)
 def updateLDAP(self):
     session = self.pg.getProprioSession()
     self.fillLoginsRegistry(session)
     for proprietaire in self.getProprietaires(session):
         ldapProprio = registry.queryAdapter(proprietaire,
                                             ILDAPProprietaire)
         dn, entryAttributes = ldapProprio.extract()
         if self.ldap.searchUser(proprietaire.id):
             if proprietaire.pro_etat == False:
                 print 'removing %s' % dn
                 self.ldap.removeUser(dn)
                 continue
             else:
                 self.ldap.updateUser(dn, entryAttributes)
         else:
             if proprietaire.pro_etat == True:
                 print 'adding %s' % dn
                 self.ldap.addUser(dn, entryAttributes)
                 self.ldap.addUserToGroup(dn, 'proprietaire')
         session.add(proprietaire)
     session.flush()
 def getId(self):
     if not bool(self.pro_log) or \
        self.pro_log == 'None' or self.pro_log == '0':
         self.pro_log = registry.queryAdapter(self, INameChooser).getLogin()
     return self.pro_log