def setupGroupTypeCombo(self): self.tr("primary","plural") self.tr("system","plural") self.tr("service","plural") grouptypeids = groupdef.list_grouptypes_by_id() self.cmb_grouptype_filter.addItem(self.tr("All","plural"),QtCore.QVariant(-1)) for i in grouptypeids: self.cmb_grouptype_filter.addItem( self.tr(groupdef.grouptype_as_text(i),"plural"), QtCore.QVariant(i)) self.connect(self.cmb_grouptype_filter,QtCore.SIGNAL('activated(int)'),self.updateGroupView)
def setupNamePage(self): self.connect(self.led_groupname,QtCore.SIGNAL("textChanged(const QString&)"),self.checkName) self.connect(self.cmb_grouptype,QtCore.SIGNAL("activated(int)"),self.updateNamePage) self.tr("primary") self.tr("system") self.tr("service") grouptypeids = groupdef.list_grouptypes_by_id() #self.cmb_usertype.addItem(self.tr("Select user type..."),QtCore.QVariant(-1)) for i in grouptypeids: self.cmb_grouptype.addItem( self.tr(groupdef.grouptype_as_text(i)), QtCore.QVariant(i)) self.cmb_grouptype.setCurrentIndex(self.cmb_grouptype.findData(QtCore.QVariant(groupdef.grouptype_as_id('service'))))
def list_groups(self,grouptype,groupname=None): if groupname==None: groupname = '*' grouptype_ids = groupdef.list_grouptypes_by_id() grouptype_objectclasses = {} for id in grouptype_ids: grouptype_objectclasses[id] = ldapdef.objectclass_by_grouptype(id) path = conf.get('LDAPSERVER','basedn') if grouptype: path = ldapdef.basedn_by_grouptype(grouptype) if not path: return {} res = self.l.search(path,ldap.SCOPE_SUBTREE,'(& (cn=%s) (objectclass=posixgroup))' % groupname ,\ ['cn','displayedName','description','gidNumber','objectClass','dn']) group_dict = {} while 1: sres = self.l.result(res,0) if sres[1]==[]: break if not sres[1][0][1].has_key('cn'): continue cn = sres[1][0][1]['cn'][0] group_dict[cn] = {} for (k,v) in sres[1][0][1].items(): if k=='objectClass': for grouptype_id,objectclasses in grouptype_objectclasses.items(): had_all_classes = True for objcls in objectclasses: if not v.count(objcls): had_all_classes = False break if had_all_classes == True: group_dict[cn]['grouptype_id'] = grouptype_id break continue if len(v)==1: group_dict[cn][k] = v[0] else: group_dict[cn][k] = v group_dict[cn]['dn'] = sres[1][0][0] return group_dict