def __init__(self, db, logger, u_sprd=None, g_sprd=None, n_sprd=None, fd=None): """ Initiate database and import modules. Spreads are given in initiation and general constants which is used in more than one method. """ timer = make_timer(logger, 'Initing PosixLDIF...') from Cerebrum.modules import PosixGroup self.db = db self.logger = logger self.const = Factory.get('Constants')(self.db) self.grp = Factory.get('Group')(self.db) self.posuser = Factory.get('PosixUser')(self.db) self.posgrp = PosixGroup.PosixGroup(self.db) self.user_dn = LDIFutils.ldapconf('USER', 'dn', None) # This is an odd one -- if set to False, then id2uname should be # populated with users exported in the users export -- which makes the # group exports filter group members by *actually* exported users... self.get_name = True self.fd = fd self.spread_d = {} # Validate spread from arg or from cereconf for x, y in zip(['USER', 'FILEGROUP', 'NETGROUP'], [u_sprd, g_sprd, n_sprd]): spread = LDIFutils.map_spreads( y or getattr(cereconf, 'LDAP_' + x).get('spread'), list) if spread: self.spread_d[x.lower()] = spread if 'user' not in self.spread_d: raise Errors.ProgrammingError( "Must specify spread-value as 'arg' or in cereconf") self.account2name = dict() self.group2gid = dict() self.groupcache = defaultdict(dict) self.group2groups = defaultdict(set) self.group2users = defaultdict(set) self.group2persons = defaultdict(list) self.shell_tab = dict() self.quarantines = dict() self.user_exporter = UserExporter(self.db) if len(self.spread_d['user']) > 1: logger.warning('Exporting users with multiple spreads, ' 'ignoring homedirs from %r', self.spread_d['user'][1:]) self.homedirs = HomedirResolver(db, self.spread_d['user'][0]) self.owners = OwnerResolver(db) auth_attr = LDIFutils.ldapconf('USER', 'auth_attr', None) self.user_password = AuthExporter.make_exporter( db, auth_attr['userPassword']) timer('... done initing PosixLDIF.')
def init_netgroup(self): """Initiate modules, constants and cache""" self.ngrp_dn = LDIFutils.ldapconf('NETGROUP', 'dn') self.cache_account2name() self.cache_groups_and_users() self.cache_group2persons() self.netgroupcache = defaultdict(dict)
def __init__(self, *args, **kwargs): super(PosixLDIFRadius, self).__init__(*args, **kwargs) auth_attr = LDIFutils.ldapconf('USER', 'auth_attr', None) self.samba_nt_password = AuthExporter.make_exporter( self.db, auth_attr['sambaNTPassword'])
def init_netgroup(self): """Initiate modules, constants and cache""" self.ngrp_dn = LDIFutils.ldapconf('NETGROUP', 'dn') self.cache_account2name() self.cache_groups_and_users() self.cache_group2persons() self.netgroupcache = defaultdict(dict)
def init_filegroup(self): """Initiate modules and constants for posixgroup""" from Cerebrum.modules import PosixGroup self.posgrp = PosixGroup.PosixGroup(self.db) self.fgrp_dn = LDIFutils.ldapconf('FILEGROUP', 'dn') self.filegroupcache = defaultdict(dict) self.cache_account2name() self.cache_group2gid() self.cache_groups_and_users()
def init_filegroup(self): """Initiate modules and constants for posixgroup""" from Cerebrum.modules import PosixGroup self.posgrp = PosixGroup.PosixGroup(self.db) self.fgrp_dn = LDIFutils.ldapconf('FILEGROUP', 'dn') self.filegroupcache = defaultdict(dict) self.cache_account2name() self.cache_group2gid() self.cache_groups_and_users()
def __init__(self): self.user_dn = LDIFutils.ldapconf('USER', 'dn', None) self.db = Factory.get('Database')() self.const = Factory.get('Constants')(self.db) self.account = Factory.get('Account')(self.db) self.auth = None for auth_type in (self.const.auth_type_crypt3_des, self.const.auth_type_md5_crypt): self.auth = self.make_auths(auth_type, self.auth) self.load_quaratines()
def __init__(self): self.user_dn = LDIFutils.ldapconf('USER', 'dn', None) self.db = Factory.get('Database')() self.const = Factory.get('Constants')(self.db) self.account = Factory.get('Account')(self.db) self.auth = None for auth_type in (self.const.auth_type_crypt3_des, self.const.auth_type_md5_crypt): self.auth = self.make_auths(auth_type, self.auth) self.load_quaratines()
def __init__(self): # Init a lot of the things we need self.samson3_dn = LDIFutils.ldapconf("SAMSON3", "dn", None) self.db = Factory.get("Database")() self.const = Factory.get("Constants")(self.db) self.account = Factory.get("Account")(self.db) self.person = Factory.get("Person")(self.db) # Collect password hashes.. self.auth = self.make_auths(self.const.auth_type_md5_crypt) # ..and quarantines.. self.load_quaratines() # ..and define a place to store the catalogobjects before writing LDIF. self.entries = []
def __init__(self): # Init a lot of the things we need self.samson3_dn = LDIFutils.ldapconf('SAMSON3', 'dn', None) self.db = Factory.get('Database')() self.const = Factory.get('Constants')(self.db) self.account = Factory.get('Account')(self.db) self.person = Factory.get('Person')(self.db) # Collect password hashes.. self.auth = self.make_auths(self.const.auth_type_md5_crypt) # ..and quarantines.. self.load_quaratines() # ..and define a place to store the catalogobjects before writing LDIF. self.entries = []
def __init__(self): self.radius_dn = LDIFutils.ldapconf('RADIUS', 'dn', None) self.db = Factory.get('Database')() self.const = Factory.get('Constants')(self.db) self.account = Factory.get('Account')(self.db) self.md4_auth = self.make_auths(self.const.auth_type_md4_nt) self.auth = None for auth_type in (self.const.auth_type_crypt3_des, self.const.auth_type_md5_crypt): self.auth = self.make_auths(auth_type, self.auth) self.load_quaratines() self.id2vlan_vpn = {} for spread in reversed(cereconf.LDAP_RADIUS['spreads']): vlan_vpn = (cereconf.LDAP_RADIUS['spread2vlan'][spread], "OU=%s;" % cereconf.LDAP_RADIUS['spread2vpn'][spread]) spread = self.const.Spread(spread) for row in self.account.search(spread=spread): self.id2vlan_vpn[row['account_id']] = vlan_vpn
def __init__(self, db, logger, u_sprd=None, g_sprd=None, n_sprd=None, fd=None): """ Initiate database and import modules. Spreads are given in initiation and general constants which is used in more than one method. """ timer = make_timer(logger, 'Initing PosixLDIF...') from Cerebrum.modules import PosixGroup self.db = db self.logger = logger self.const = Factory.get('Constants')(self.db) self.grp = Factory.get('Group')(self.db) self.posuser = Factory.get('PosixUser')(self.db) self.posgrp = PosixGroup.PosixGroup(self.db) self.user_dn = LDIFutils.ldapconf('USER', 'dn', None) self.get_name = True self.fd = fd self.spread_d = {} # Validate spread from arg or from cereconf for x, y in zip(['USER', 'FILEGROUP', 'NETGROUP'], [u_sprd, g_sprd, n_sprd]): spread = LDIFutils.map_spreads( y or getattr(cereconf, 'LDAP_' + x).get('spread'), list) if spread: self.spread_d[x.lower()] = spread if 'user' not in self.spread_d: raise Errors.ProgrammingError( "Must specify spread-value as 'arg' or in cereconf") self.account2name = dict() self.groupcache = defaultdict(dict) self.group2groups = defaultdict(set) self.group2users = defaultdict(set) self.group2persons = defaultdict(list) timer('... done initing PosixLDIF.')
def __init__(self, db, logger, u_sprd=None, g_sprd=None, n_sprd=None, fd=None): """ Initiate database and import modules. Spreads are given in initiation and general constants which is used in more than one method. """ timer = make_timer(logger, 'Initing PosixLDIF...') from Cerebrum.modules import PosixGroup self.db = db self.logger = logger self.const = Factory.get('Constants')(self.db) self.grp = Factory.get('Group')(self.db) self.posuser = Factory.get('PosixUser')(self.db) self.posgrp = PosixGroup.PosixGroup(self.db) self.user_dn = LDIFutils.ldapconf('USER', 'dn', None) self.get_name = True self.fd = fd self.spread_d = {} # Validate spread from arg or from cereconf for x, y in zip(['USER', 'FILEGROUP', 'NETGROUP'], [u_sprd, g_sprd, n_sprd]): spread = LDIFutils.map_spreads( y or getattr(cereconf, 'LDAP_' + x).get('spread'), list) if spread: self.spread_d[x.lower()] = spread if 'user' not in self.spread_d: raise Errors.ProgrammingError( "Must specify spread-value as 'arg' or in cereconf") self.account2name = dict() self.groupcache = defaultdict(dict) self.group2groups = defaultdict(set) self.group2users = defaultdict(set) self.group2persons = defaultdict(list) timer('... done initing PosixLDIF.')