def write(self, dn, attributes, parameters): # get group names and check against requested group name names = attributes['cn'] if 'cn' in parameters: if parameters['cn'] not in names: return names = ( parameters['cn'], ) # get group group password passwd = attributes['userPassword'][0] # get group id(s) gids = ( parameters['gidNumber'], ) if 'gidNumber' in parameters else attributes['gidNumber'] gids = [ int(x) for x in gids ] # build member list members = set() if self.wantmembers: # add the memberUid values for member in clean(attributes['memberUid']): if common.isvalidname(member): members.add(member) # translate and add the member values for memberdn in clean(attributes['member']): member = dn2uid(self.conn, memberdn) if member and common.isvalidname(member): members.add(member) # actually return the results for name in names: if not common.isvalidname(name): print 'Warning: group entry %s contains invalid group name: "%s"' % ( dn, name ) else: for gid in gids: self.fp.write_int32(constants.NSLCD_RESULT_BEGIN) self.fp.write_string(name) self.fp.write_string(passwd) self.fp.write_gid_t(gid) self.fp.write_stringlist(members)
def get_members(self, attributes, members, subgroups, seen): # add the memberUid values for member in clean(attributes['memberUid']): if common.is_valid_name(member): members.add(member) # translate and add the member values for memberdn in clean(attributes['member']): if memberdn in seen: continue seen.add(memberdn) member = passwd.dn2uid(self.conn, memberdn) if member and common.is_valid_name(member): members.add(member) elif cfg.nss_nested_groups: subgroups.append(memberdn)
def get_members(self, attributes, members, subgroups, seen): # add the memberUid values for member in clean(attributes['memberUid']): if common.isvalidname(member): members.add(member) # translate and add the member values for memberdn in clean(attributes['member']): if memberdn in seen: continue seen.add(memberdn) member = passwd.dn2uid(self.conn, memberdn) if member and common.isvalidname(member): members.add(member) elif cfg.nss_nested_groups: subgroups.append(memberdn)