Esempio n. 1
0
def _cache_keys_NIS(**kwargs):
    nis = FreeNAS_NIS(flags=FLAGS_DBINIT)
    domains = nis.get_domains()
    for d in domains:
        print("d: %s" % d)

        ucache = FreeNAS_UserCache(dir=d)
        if ucache:
            for key in list(ucache.keys()):
                print("u key: %s" % key)

        gcache = FreeNAS_GroupCache(dir=d)
        if gcache:
            for key in list(gcache.keys()):
                print("g key: %s" % key)

        ducache = FreeNAS_Directory_UserCache(dir=d)
        if ducache:
            for key in list(ducache.keys()):
                print("du key: %s" % key)

        dgcache = FreeNAS_Directory_GroupCache(dir=d)
        if dgcache:
            for key in list(dgcache.keys()):
                print("dg key: %s" % key)
Esempio n. 2
0
def _cache_rawdump_NT4(**kwargs):
    nt4 = FreeNAS_NT4()
    domains = nt4.get_domains()
    for d in domains:
        workgroup = d 

        print "w: %s" % workgroup 

        ucache = FreeNAS_UserCache(dir=workgroup)
        if ucache:
            for key in ucache.keys():
                print "u: %s=%s" % (key, ucache[key])

        gcache = FreeNAS_GroupCache(dir=workgroup)
        if gcache:
            for key in gcache.keys():
                print "g: %s=%s" % (key, gcache[key])

        ducache = FreeNAS_Directory_UserCache(dir=workgroup)
        if ducache:
            for key in ducache.keys():
                print "du: %s=%s" % (key, ducache[key])

        dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)
        if dgcache:
            for key in dgcache.keys():
                print "dg: %s=%s" % (key, dgcache[key])
Esempio n. 3
0
def _cache_keys_NT4(**kwargs):
    nt4 = FreeNAS_NT4()
    domains = nt4.get_domains()
    for d in domains:
        workgroup = d

        print("w: %s" % workgroup)

        ucache = FreeNAS_UserCache(dir=workgroup)
        if ucache:
            for key in list(ucache.keys()):
                print("u key: %s" % key)

        gcache = FreeNAS_GroupCache(dir=workgroup)
        if gcache:
            for key in list(gcache.keys()):
                print("g key: %s" % key)

        ducache = FreeNAS_Directory_UserCache(dir=workgroup)
        if ducache:
            for key in list(ducache.keys()):
                print("du key: %s" % key)

        dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)
        if dgcache:
            for key in list(dgcache.keys()):
                print("dg key: %s" % key)
Esempio n. 4
0
def _cache_keys_NIS(**kwargs):
    nis = FreeNAS_NIS(flags=FLAGS_DBINIT)
    domains = nis.get_domains()
    for d in domains:
        print "d: %s" % d

        ucache = FreeNAS_UserCache(dir=d)
        if ucache:
            for key in ucache.keys():
                print "u key: %s" % key

        gcache = FreeNAS_GroupCache(dir=d)
        if gcache:
            for key in gcache.keys():
                print "g key: %s" % key

        ducache = FreeNAS_Directory_UserCache(dir=d)
        if ducache:
            for key in ducache.keys():
                print "du key: %s" % key

        dgcache = FreeNAS_Directory_GroupCache(dir=d)
        if dgcache:
            for key in dgcache.keys():
                print "dg key: %s" % key
Esempio n. 5
0
def _cache_keys_NIS(**kwargs):
    nis = FreeNAS_NIS(flags=FLAGS_DBINIT)
    domains = nis.get_domains()
    for d in domains:
        print "d: %s" % d

        ucache = FreeNAS_UserCache(dir=d)
        if ucache: 
            for key in ucache.keys():
                print "u key: %s" % key

        gcache = FreeNAS_GroupCache(dir=d)
        if gcache:
            for key in gcache.keys():
                print "g key: %s" % key

        ducache = FreeNAS_Directory_UserCache(dir=d)
        if ducache:
            for key in ducache.keys():
                print "du key: %s" % key

        dgcache = FreeNAS_Directory_GroupCache(dir=d)
        if dgcache:
            for key in dgcache.keys():
                print "dg key: %s" % key
Esempio n. 6
0
def _cache_check_default(**kwargs):
    if not kwargs.has_key('args') and kwargs['args']:
        return

    ucache = FreeNAS_UserCache()
    gcache = FreeNAS_GroupCache()
    ducache = FreeNAS_Directory_UserCache()
    dgcache = FreeNAS_Directory_GroupCache()

    for arg in kwargs['args']:
        key = val = None
        try:
            parts = arg.split('=')
            key = parts[0]
            val = join(parts[1:], '=')

        except:
            continue

        if key == 'u':
            if ucache and ucache.has_key(val) and ucache[val]:
                print "%s: %s" % (val, ucache[val])

        elif key == 'g':
            if gcache and gcache.has_key(val) and gcache[val]:
                print "%s: %s" % (val, gcache[val])

        elif key == 'du':
            if ducache and ducache.has_key(val) and ducache[val]:
                print "%s: %s" % (val, ducache[val])

        elif key == 'dg':
            if dgcache and dgcache.has_key(val) and dgcache[val]:
                print "%s: %s" % (val, dgcache[val])
Esempio n. 7
0
def _cache_rawdump_NT4(**kwargs):
    nt4 = FreeNAS_NT4()
    domains = nt4.get_domains()
    for d in domains:
        workgroup = d

        print "w: %s" % workgroup

        ucache = FreeNAS_UserCache(dir=workgroup)
        if ucache:
            for key in ucache.keys():
                print "u: %s=%s" % (key, ucache[key])

        gcache = FreeNAS_GroupCache(dir=workgroup)
        if gcache:
            for key in gcache.keys():
                print "g: %s=%s" % (key, gcache[key])

        ducache = FreeNAS_Directory_UserCache(dir=workgroup)
        if ducache:
            for key in ducache.keys():
                print "du: %s=%s" % (key, ducache[key])

        dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)
        if dgcache:
            for key in dgcache.keys():
                print "dg: %s=%s" % (key, dgcache[key])
Esempio n. 8
0
def _cache_rawdump_NIS(**kwargs):
    nis = FreeNAS_NIS(flags=FLAGS_DBINIT)
    domains = nis.get_domains()
    for d in domains:
        print("d: %s" % d)

        ucache = FreeNAS_UserCache(dir=d)
        if ucache:
            for key in list(ucache.keys()):
                print("u: %s=%s" % (key, ucache[key]))

        gcache = FreeNAS_GroupCache(dir=d)
        if gcache:
            for key in list(gcache.keys()):
                print("g: %s=%s" % (key, gcache[key]))

        ducache = FreeNAS_Directory_UserCache(dir=d)
        if ducache:
            for key in list(ducache.keys()):
                print("du: %s=%s" % (key, ducache[key]))

        dgcache = FreeNAS_Directory_GroupCache(dir=d)
        if dgcache:
            for key in list(dgcache.keys()):
                print("dg: %s=%s" % (key, dgcache[key]))
Esempio n. 9
0
def _cache_keys_ActiveDirectory(**kwargs):
    ad = FreeNAS_ActiveDirectory(flags=FLAGS_DBINIT)
    domains = ad.get_domains()
    for d in domains:
        workgroup = d['nETBIOSName']

        print "w: %s" % workgroup 

        ucache = FreeNAS_UserCache(dir=workgroup)
        if ucache: 
            for key in ucache.keys():
                print "u key: %s" % key

        gcache = FreeNAS_GroupCache(dir=workgroup)
        if gcache:
            for key in gcache.keys():
                print "g key: %s" % key

        ducache = FreeNAS_Directory_UserCache(dir=workgroup)
        if ducache:
            for key in ducache.keys():
                print "du key: %s" % key

        dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)
        if dgcache:
            for key in dgcache.keys():
                print "dg key: %s" % key
Esempio n. 10
0
def _cache_keys_NIS(**kwargs):
    nis = FreeNAS_NIS(flags=FLAGS_DBINIT)
    domains = nis.get_domains()
    for d in domains:
        print("d: %s" % d)

        ucache = FreeNAS_UserCache(dir=d)
        if ucache:
            for key in list(ucache.keys()):
                print("u key: %s" % key)

        gcache = FreeNAS_GroupCache(dir=d)
        if gcache:
            for key in list(gcache.keys()):
                print("g key: %s" % key)

        ducache = FreeNAS_Directory_UserCache(dir=d)
        if ducache:
            for key in list(ducache.keys()):
                print("du key: %s" % key)

        dgcache = FreeNAS_Directory_GroupCache(dir=d)
        if dgcache:
            for key in list(dgcache.keys()):
                print("dg key: %s" % key)
Esempio n. 11
0
def _cache_keys_NT4(**kwargs):
    nt4 = FreeNAS_NT4()
    domains = nt4.get_domains()
    for d in domains:
        workgroup = d

        print "w: %s" % workgroup 

        ucache = FreeNAS_UserCache(dir=workgroup)
        if ucache:
            for key in ucache.keys():
                print "u key: %s" % key

        gcache = FreeNAS_GroupCache(dir=workgroup)
        if gcache:
            for key in gcache.keys():
                print "g key: %s" % key

        ducache = FreeNAS_Directory_UserCache(dir=workgroup)
        if ducache:
            for key in ducache.keys():
                print "du key: %s" % key

        dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)
        if dgcache:
            for key in dgcache.keys():
                print "dg key: %s" % key
Esempio n. 12
0
def _cache_rawdump_ActiveDirectory(**kwargs):
    ad = FreeNAS_ActiveDirectory(flags=FLAGS_DBINIT)
    domains = ad.get_domains()
    for d in domains:
        workgroup = d['nETBIOSName']

        print "w: %s" % workgroup

        ucache = FreeNAS_UserCache(dir=workgroup)
        if ucache:
            for key in ucache.keys():
                print "u: %s=%s" % (key, ucache[key])

        gcache = FreeNAS_GroupCache(dir=workgroup)
        if gcache:
            for key in gcache.keys():
                print "g: %s=%s" % (key, gcache[key])

        ducache = FreeNAS_Directory_UserCache(dir=workgroup)
        if ducache:
            for key in ducache.keys():
                print "du: %s=%s" % (key, ducache[key])

        dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)
        if dgcache:
            for key in dgcache.keys():
                print "dg: %s=%s" % (key, dgcache[key])
Esempio n. 13
0
def _cache_rawdump_NIS(**kwargs):
    nis = FreeNAS_NIS(flags=FLAGS_DBINIT)
    domains = nis.get_domains()
    for d in domains:
        print "d: %s" % d

        ucache = FreeNAS_UserCache(dir=d)
        if ucache:
            for key in ucache.keys():
                print "u: %s=%s" % (key, ucache[key])

        gcache = FreeNAS_GroupCache(dir=d)
        if gcache:
            for key in gcache.keys():
                print "g: %s=%s" % (key, gcache[key])

        ducache = FreeNAS_Directory_UserCache(dir=d)
        if ducache:
            for key in ducache.keys():
                print "du: %s=%s" % (key, ducache[key])

        dgcache = FreeNAS_Directory_GroupCache(dir=d)
        if dgcache:
            for key in dgcache.keys():
                print "dg: %s=%s" % (key, dgcache[key])
Esempio n. 14
0
def _cache_keys_NT4(**kwargs):
    nt4 = FreeNAS_NT4()
    domains = nt4.get_domains()
    for d in domains:
        workgroup = d

        print "w: %s" % workgroup

        ucache = FreeNAS_UserCache(dir=workgroup)
        if ucache:
            for key in ucache.keys():
                print "u key: %s" % key

        gcache = FreeNAS_GroupCache(dir=workgroup)
        if gcache:
            for key in gcache.keys():
                print "g key: %s" % key

        ducache = FreeNAS_Directory_UserCache(dir=workgroup)
        if ducache:
            for key in ducache.keys():
                print "du key: %s" % key

        dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)
        if dgcache:
            for key in dgcache.keys():
                print "dg key: %s" % key
Esempio n. 15
0
def _cache_keys_ActiveDirectory(**kwargs):
    ad = FreeNAS_ActiveDirectory(flags=FLAGS_DBINIT)
    domains = ad.get_domains()
    for d in domains:
        workgroup = d['nETBIOSName']

        print "w: %s" % workgroup

        ucache = FreeNAS_UserCache(dir=workgroup)
        if ucache:
            for key in ucache.keys():
                print "u key: %s" % key

        gcache = FreeNAS_GroupCache(dir=workgroup)
        if gcache:
            for key in gcache.keys():
                print "g key: %s" % key

        ducache = FreeNAS_Directory_UserCache(dir=workgroup)
        if ducache:
            for key in ducache.keys():
                print "du key: %s" % key

        dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)
        if dgcache:
            for key in dgcache.keys():
                print "dg key: %s" % key
Esempio n. 16
0
def _cache_rawdump_ActiveDirectory(**kwargs):
    ad = FreeNAS_ActiveDirectory(flags=FLAGS_DBINIT)
    domains = ad.get_domains()
    for d in domains:
        workgroup = d['nETBIOSName']

        print "w: %s" % workgroup 

        ucache = FreeNAS_UserCache(dir=workgroup)
        if ucache:
            for key in ucache.keys():
                print "u: %s=%s" % (key, ucache[key])

        gcache = FreeNAS_GroupCache(dir=workgroup)
        if gcache:
            for key in gcache.keys():
                print "g: %s=%s" % (key, gcache[key])

        ducache = FreeNAS_Directory_UserCache(dir=workgroup)
        if ducache:
            for key in ducache.keys():
                print "du: %s=%s" % (key, ducache[key])

        dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)
        if dgcache:
            for key in dgcache.keys():
                print "dg: %s=%s" % (key, dgcache[key])
Esempio n. 17
0
def _cache_check_default(**kwargs):
    if not kwargs.has_key('args') and kwargs['args']:
        return

    ucache = FreeNAS_UserCache()
    gcache = FreeNAS_GroupCache()
    ducache = FreeNAS_Directory_UserCache()
    dgcache = FreeNAS_Directory_GroupCache()

    for arg in kwargs['args']:
        key = val = None
        try:
            parts = arg.split('=')
            key = parts[0]
            val = join(parts[1:], '=')

        except:
            continue

        if key == 'u':
            if ucache and ucache.has_key(val) and ucache[val]:
                print "%s: %s" % (val, ucache[val])

        elif key == 'g':
            if gcache and gcache.has_key(val) and gcache[val]:
                print "%s: %s" % (val, gcache[val])

        elif key == 'du':
            if ducache and ducache.has_key(val) and ducache[val]:
                print "%s: %s" % (val, ducache[val])

        elif key == 'dg':
            if dgcache and dgcache.has_key(val) and dgcache[val]:
                print "%s: %s" % (val, dgcache[val])
Esempio n. 18
0
    def __init__(self, **kwargs):
        log.debug("FreeNAS_DomainController_Groups.__init__: enter")

        super(FreeNAS_DomainController_Groups, self).__init__(**kwargs)

        self.__groups = {}
        self.__gcache = {}
        self.__dgcache = {}

        if 'domain' in kwargs and kwargs['domain']:
            self.__domains = self.get_domains(domain=kwargs['domain'])
        else:
            self.__domains = [self.get_domain()]

        if (
            (self.flags & FLAGS_CACHE_READ_GROUP) or
            (self.flags & FLAGS_CACHE_WRITE_GROUP)
        ):
            for d in self.__domains:
                self.__gcache[d] = FreeNAS_GroupCache(dir=d)
                self.__dgcache[d] = FreeNAS_DomainController_GroupCache(dir=d)

        self.__get_groups()

        log.debug("FreeNAS_DomainController_Groups.__init__: leave")
Esempio n. 19
0
def _cache_rawdump_default(**kwargs):
    ucache = FreeNAS_UserCache()
    for key in list(ucache.keys()):
        print("u: %s=%s" % (key, ucache[key]))

    gcache = FreeNAS_GroupCache()
    if gcache:
        for key in list(gcache.keys()):
            print("g: %s=%s" % (key, gcache[key]))

    ducache = FreeNAS_Directory_UserCache()
    if ducache:
        for key in list(ducache.keys()):
            print("du: %s=%s" % (key, ducache[key]))

    dgcache = FreeNAS_Directory_GroupCache()
    if dgcache:
        for key in list(dgcache.keys()):
            print("dg: %s=%s" % (key, dgcache[key]))
Esempio n. 20
0
def _cache_count_NIS(**kwargs):
    nis = FreeNAS_NIS(flags=FLAGS_DBINIT)
    domains = nis.get_domains()
    for d in domains:
        print("d:  %s" % d)
        print("u:  %ld" % _cachelen(FreeNAS_UserCache(dir=d)))
        print("g:  %ld" % _cachelen(FreeNAS_GroupCache(dir=d)))
        print("du: %ld" % _cachelen(FreeNAS_Directory_UserCache(dir=d)))
        print("dg: %ld" % _cachelen(FreeNAS_Directory_GroupCache(dir=d)))
        print("\n")
Esempio n. 21
0
def _cache_rawdump_default(**kwargs):
    ucache = FreeNAS_UserCache()
    for key in list(ucache.keys()):
        print("u: %s=%s" % (key, ucache[key]))

    gcache = FreeNAS_GroupCache()
    if gcache:
        for key in list(gcache.keys()):
            print("g: %s=%s" % (key, gcache[key]))

    ducache = FreeNAS_Directory_UserCache()
    if ducache:
        for key in list(ducache.keys()):
            print("du: %s=%s" % (key, ducache[key]))

    dgcache = FreeNAS_Directory_GroupCache()
    if dgcache:
        for key in list(dgcache.keys()):
            print("dg: %s=%s" % (key, dgcache[key]))
Esempio n. 22
0
def _cache_rawdump_default(**kwargs):
    ucache = FreeNAS_UserCache()
    for key in ucache.keys():
        print "u: %s=%s" % (key, ucache[key])

    gcache = FreeNAS_GroupCache()
    if gcache:
        for key in gcache.keys():
            print "g: %s=%s" % (key, gcache[key])

    ducache = FreeNAS_Directory_UserCache()
    if ducache:
        for key in ducache.keys():
            print "du: %s=%s" % (key, ducache[key])

    dgcache = FreeNAS_Directory_GroupCache()
    if dgcache:
        for key in dgcache.keys():
            print "dg: %s=%s" % (key, dgcache[key])
Esempio n. 23
0
def _cache_rawdump_default(**kwargs):
    ucache = FreeNAS_UserCache()
    for key in ucache.keys():
        print "u: %s=%s" % (key, ucache[key])

    gcache = FreeNAS_GroupCache()
    if gcache:
        for key in gcache.keys():
            print "g: %s=%s" % (key, gcache[key])

    ducache = FreeNAS_Directory_UserCache()
    if ducache:
        for key in ducache.keys():
            print "du: %s=%s" % (key, ducache[key])

    dgcache = FreeNAS_Directory_GroupCache()
    if dgcache:
        for key in dgcache.keys():
            print "dg: %s=%s" % (key, dgcache[key])
Esempio n. 24
0
    def __init__(self, **kwargs):
        super(FreeNAS_LDAP_Groups, self).__init__(**kwargs)

        if ((self.flags & FLAGS_CACHE_READ_GROUP)
                or (self.flags & FLAGS_CACHE_WRITE_GROUP)):
            self.__gcache = FreeNAS_GroupCache()
            self.__dgcache = FreeNAS_Directory_GroupCache()

        self.__groups = []
        self.__groupnames = []
        self.__get_groups()
Esempio n. 25
0
def _cache_keys_default(**kwargs):
    ucache = FreeNAS_UserCache()
    if ucache:
        for key in list(ucache.keys()):
            print("u key: %s" % key)

    gcache = FreeNAS_GroupCache()
    if gcache:
        for key in list(gcache.keys()):
            print("g key: %s" % key)

    ducache = FreeNAS_Directory_UserCache()
    if ducache:
        for key in list(ducache.keys()):
            print("du key: %s" % key)

    dgcache = FreeNAS_Directory_GroupCache()
    if dgcache:
        for key in list(dgcache.keys()):
            print("dg key: %s" % key)
Esempio n. 26
0
def _cache_keys_default(**kwargs):
    ucache = FreeNAS_UserCache()
    if ucache:
        for key in list(ucache.keys()):
            print("u key: %s" % key)

    gcache = FreeNAS_GroupCache()
    if gcache:
        for key in list(gcache.keys()):
            print("g key: %s" % key)

    ducache = FreeNAS_Directory_UserCache()
    if ducache:
        for key in list(ducache.keys()):
            print("du key: %s" % key)

    dgcache = FreeNAS_Directory_GroupCache()
    if dgcache:
        for key in list(dgcache.keys()):
            print("dg key: %s" % key)
Esempio n. 27
0
def _cache_keys_default(**kwargs):
    ucache = FreeNAS_UserCache()
    if ucache:
        for key in ucache.keys():
            print "u key: %s" % key

    gcache = FreeNAS_GroupCache()
    if gcache:
        for key in gcache.keys():
            print "g key: %s" % key

    ducache = FreeNAS_Directory_UserCache()
    if ducache:
        for key in ducache.keys():
            print "du key: %s" % key

    dgcache = FreeNAS_Directory_GroupCache()
    if dgcache:
        for key in dgcache.keys():
            print "dg key: %s" % key
Esempio n. 28
0
def _cache_keys_default(**kwargs):
    ucache = FreeNAS_UserCache()
    if ucache:
        for key in ucache.keys():
            print "u key: %s" % key

    gcache = FreeNAS_GroupCache()
    if gcache:
        for key in gcache.keys():
            print "g key: %s" % key

    ducache = FreeNAS_Directory_UserCache()
    if ducache:
        for key in ducache.keys():
            print "du key: %s" % key

    dgcache = FreeNAS_Directory_GroupCache()
    if dgcache:
        for key in dgcache.keys():
            print "dg key: %s" % key
Esempio n. 29
0
def _cache_count_NT4(**kwargs):
    nt4 = FreeNAS_NT4()
    domains = nt4.get_domains()
    for d in domains:
        workgroup = d

        print "w:  %s" % workgroup
        print "u:  %ld" % _cachelen(FreeNAS_UserCache(dir=workgroup))
        print "g:  %ld" % _cachelen(FreeNAS_GroupCache(dir=workgroup))
        print "du: %ld" % _cachelen(FreeNAS_NT4_UserCache(dir=workgroup))
        print "dg: %ld" % _cachelen(FreeNAS_NT4_GroupCache(dir=workgroup))
        print "\n"
Esempio n. 30
0
def _cache_count_ActiveDirectory(**kwargs):
    ad = FreeNAS_ActiveDirectory(flags=FLAGS_DBINIT)
    domains = ad.get_domains()
    for d in domains:
        workgroup = d['nETBIOSName']

        print "w:  %s" % workgroup
        print "u:  %ld" % _cachelen(FreeNAS_UserCache(dir=workgroup))
        print "g:  %ld" % _cachelen(FreeNAS_GroupCache(dir=workgroup))
        print "du: %ld" % _cachelen(FreeNAS_Directory_UserCache(dir=workgroup))
        print "dg: %ld" % _cachelen(
            FreeNAS_Directory_GroupCache(dir=workgroup))
        print "\n"
Esempio n. 31
0
    def __init__(self, group, **kwargs):
        log.debug("FreeNAS_LDAP_Group.__init__: group = %s", group)

        super(FreeNAS_LDAP_Group, self).__init__(**kwargs)

        if ((self.flags & FLAGS_CACHE_READ_GROUP)
                or (self.flags & FLAGS_CACHE_WRITE_GROUP)):
            self.__gcache = FreeNAS_GroupCache()
            self.__dgcache = FreeNAS_Directory_GroupCache()
            if self.groupsuffix and self.basedn:
                self.__key = str("cn=%s,%s,%s" %
                                 (group, self.groupsuffix, self.basedn))
            elif self.basedn:
                self.__key = str("cn=%s,%s" % (group, self.basedn))

        self._gr = None
        if group:
            self.__get_group(group)
Esempio n. 32
0
    def __init__(self, group, **kwargs):
        log.debug("FreeNAS_DomainController_Group.__init__: enter")
        log.debug("FreeNAS_DomainController_Group.__init__: group = %s", group)

        parts = group.split(FREENAS_DOMAINCONTROLLER_SEPARATOR)
        domain = parts[0]

        self._gr = None

        kwargs['domain'] = domain
        super(FreeNAS_DomainController_Group, self).__init__(**kwargs)

        if (
            (self.flags & FLAGS_CACHE_READ_GROUP) or
            (self.flags & FLAGS_CACHE_WRITE_GROUP)
        ):
            self.__gcache = FreeNAS_GroupCache()
            self.__dgcache = FreeNAS_DomainController_GroupCache(dir=domain)
            self.__key = group

        self.__get_group(group, domain)

        log.debug("FreeNAS_DomainController_Group.__init__: leave")
Esempio n. 33
0
def _cache_count_default(**kwargs):
    print("u:  %ld" % _cachelen(FreeNAS_UserCache()))
    print("g:  %ld" % _cachelen(FreeNAS_GroupCache()))
    print("du: %ld" % _cachelen(FreeNAS_Directory_UserCache()))
    print("dg: %ld" % _cachelen(FreeNAS_Directory_GroupCache()))
    print("\n")
Esempio n. 34
0
def _cache_check_ActiveDirectory(**kwargs):
    if not kwargs.has_key('args') and kwargs['args']:
        return

    valid = {}
    ad = FreeNAS_ActiveDirectory(flags=FLAGS_DBINIT)
    domains = ad.get_domains()
    for d in domains:
        workgroup = d['nETBIOSName']
        valid[workgroup] = True

    for arg in kwargs['args']:
        key = val = None

        if arg.startswith("u="):
            key = "u"
            val = arg.partition("u=")[2]

        elif arg.startswith("g="):
            key = "g"
            val = arg.partition("g=")[2]

        elif arg.startswith("du="):
            key = "du"
            val = arg.partition("du=")[2]

        elif arg.startswith("dg="):
            key = "dg"
            val = arg.partition("dg=")[2]

        else:
            continue

        if key in ('u', 'g'):
            parts = val.split('\\')
            if len(parts) < 2:
                continue

            workgroup = parts[0]
            if not valid.has_key(workgroup):
                continue

            ucache = FreeNAS_UserCache(dir=workgroup)
            gcache = FreeNAS_GroupCache(dir=workgroup)
            ducache = FreeNAS_Directory_UserCache(dir=workgroup)
            dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)

            if key == 'u':
                if ucache and ucache.has_key(val) and ucache[val]:
                    print "%s: %s" % (val, ucache[val])

            elif key == 'g':
                if gcache and gcache.has_key(val) and gcache[val]:
                    print "%s: %s" % (val, gcache[val])

        elif key in ('du', 'dg'):
            for workgroup in valid.keys():
                ucache = FreeNAS_UserCache(dir=workgroup)
                gcache = FreeNAS_GroupCache(dir=workgroup)
                ducache = FreeNAS_Directory_UserCache(dir=workgroup)
                dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)

                if key == 'du':
                    if ducache and ducache.has_key(val) and ducache[val]:
                        print "%s: %s" % (val, ducache[val])

                elif key == 'dg':
                    if dgcache and dgache.has_key(val) and dgcache[val]:
                        print "%s: %s" % (val, dgcache[val])
Esempio n. 35
0
def _cache_check_NIS(**kwargs):
    if 'args' not in kwargs and kwargs['args']:
        return

    valid = {}
    nis = FreeNAS_NIS(flags=FLAGS_DBINIT)
    domains = nis.get_domains()
    for d in domains:
        valid[d] = True

    for arg in kwargs['args']:
        key = val = None

        if arg.startswith("u="):
            key = "u"
            val = arg.partition("u=")[2]

        elif arg.startswith("g="):
            key = "g"
            val = arg.partition("g=")[2]

        elif arg.startswith("du="):
            key = "du"
            val = arg.partition("du=")[2]

        elif arg.startswith("dg="):
            key = "dg"
            val = arg.partition("dg=")[2]

        else:
            continue

        if key in ('u', 'g'):
            parts = val.split('\\')
            if len(parts) < 2:
                continue

            d = parts[0]
            if d not in valid:
                continue

            ucache = FreeNAS_UserCache(dir=d)
            gcache = FreeNAS_GroupCache(dir=d)
            ducache = FreeNAS_Directory_UserCache(dir=d)
            dgcache = FreeNAS_Directory_GroupCache(dir=d)

            if key == 'u':
                if ucache and val in ucache and ucache[val]:
                    print("%s: %s" % (val, ucache[val]))

            elif key == 'g':
                if gcache and val in gcache and gcache[val]:
                    print("%s: %s" % (val, gcache[val]))

        elif key in ('du', 'dg'):
            for d in list(valid.keys()):
                ucache = FreeNAS_UserCache(dir=d)
                gcache = FreeNAS_GroupCache(dir=d)
                ducache = FreeNAS_Directory_UserCache(dir=d)
                dgcache = FreeNAS_Directory_GroupCache(dir=d)

                if key == 'du':
                    if ducache and val in ducache and ducache[val]:
                        print("%s: %s" % (val, ducache[val]))

                elif key == 'dg':
                    if dgcache and val in dgcache and dgcache[val]:
                        print("%s: %s" % (val, dgcache[val]))
Esempio n. 36
0
def _cache_check_NT4(**kwargs):
    if not ('args' in kwargs and kwargs['args']):
        return

    valid = {}
    nt4 = FreeNAS_NT4()
    domains = nt4.get_domains()
    for d in domains:
        workgroup = d
        valid[workgroup] = True

    for arg in kwargs['args']:
        key = val = None

        if arg.startswith("u="):
            key = "u"
            val = arg.partition("u=")[2]

        elif arg.startswith("g="):
            key = "g"
            val = arg.partition("g=")[2]

        elif arg.startswith("du="):
            key = "du"
            val = arg.partition("du=")[2]

        elif arg.startswith("dg="):
            key = "dg"
            val = arg.partition("dg=")[2]

        else:
            continue

        if key in ('u', 'g'):
            parts = val.split('\\')
            if len(parts) < 2:
                continue

            workgroup = parts[0]
            if workgroup not in valid:
                continue

            ucache = FreeNAS_UserCache(dir=workgroup)
            gcache = FreeNAS_GroupCache(dir=workgroup)
            ducache = FreeNAS_Directory_UserCache(dir=workgroup)
            dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)

            if key == 'u':
                if ucache and val in ucache and ucache[val]:
                    print "%s: %s" % (val, ucache[val])

            elif key == 'g':
                if gcache and val in gcache and gcache[val]:
                    print "%s: %s" % (val, gcache[val])

        elif key in ('du', 'dg'):
            for workgroup in valid.keys():
                ucache = FreeNAS_UserCache(dir=workgroup)
                gcache = FreeNAS_GroupCache(dir=workgroup)
                ducache = FreeNAS_Directory_UserCache(dir=workgroup)
                dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)

                if key == 'du':
                    if ducache and val in ducache and ducache[val]:
                        print "%s: %s" % (val, ducache[val])

                elif key == 'dg':
                    if dgcache and val in dgcache and dgcache[val]:
                        print "%s: %s" % (val, dgcache[val])
Esempio n. 37
0
def _cache_check_NIS(**kwargs):
    if not kwargs.has_key('args') and kwargs['args']:
        return

    valid = {}
    ad = FreeNAS_NIS(flags=FLAGS_DBINIT)
    domains = nis.get_domains()
    for d in domains:
        valid[d] = True

    for arg in kwargs['args']:
        key = val = None

        if arg.startswith("u="): 
            key = "u"
            val = arg.partition("u=")[2]

        elif arg.startswith("g="): 
            key = "g"
            val = arg.partition("g=")[2]

        elif arg.startswith("du="): 
            key = "du"
            val = arg.partition("du=")[2]

        elif arg.startswith("dg="): 
            key = "dg"
            val = arg.partition("dg=")[2]

        else:
            continue


        if key in ('u', 'g'):
            parts = val.split('\\')
            if len(parts) < 2:
                continue

            d = parts[0]
            if not valid.has_key(d):
                continue

            ucache = FreeNAS_UserCache(dir=d)
            gcache = FreeNAS_GroupCache(dir=d)
            ducache = FreeNAS_Directory_UserCache(dir=d)
            dgcache = FreeNAS_Directory_GroupCache(dir=d)

            if key == 'u':
                if ucache and ucache.has_key(val) and ucache[val]:
                    print "%s: %s" % (val, ucache[val])

            elif key == 'g':
                if gcache and gcache.has_key(val) and gcache[val]:
                    print "%s: %s" % (val, gcache[val])


        elif key in ('du', 'dg'):
            for d in valid.keys():
                ucache = FreeNAS_UserCache(dir=d)
                gcache = FreeNAS_GroupCache(dir=d)
                ducache = FreeNAS_Directory_UserCache(dir=d)
                dgcache = FreeNAS_Directory_GroupCache(dir=d)

                if key == 'du':
                    if ducache and ducache.has_key(val) and ducache[val]:
                        print "%s: %s" % (val, ducache[val])

                elif key == 'dg':
                    if dgcache and dgache.has_key(val) and dgcache[val]:
                        print "%s: %s" % (val, dgcache[val])
Esempio n. 38
0
def _cache_check_NT4(**kwargs):
    if not kwargs.has_key('args') and kwargs['args']:
        return

    valid = {}
    nt4 = FreeNAS_NT4()
    domains = nt4.get_domains()
    for d in domains:
        workgroup = d
        valid[workgroup] = True

    for arg in kwargs['args']:
        key = val = None

        if arg.startswith("u="): 
            key = "u"
            val = arg.partition("u=")[2]

        elif arg.startswith("g="): 
            key = "g"
            val = arg.partition("g=")[2]

        elif arg.startswith("du="): 
            key = "du"
            val = arg.partition("du=")[2]

        elif arg.startswith("dg="): 
            key = "dg"
            val = arg.partition("dg=")[2]

        else:
            continue


        if key in ('u', 'g'):
            parts = val.split('\\')
            if len(parts) < 2:
                continue

            workgroup = parts[0]
            if not valid.has_key(workgroup):
                continue

            ucache = FreeNAS_UserCache(dir=workgroup)
            gcache = FreeNAS_GroupCache(dir=workgroup)
            ducache = FreeNAS_Directory_UserCache(dir=workgroup)
            dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)

            if key == 'u':
                if ucache and ucache.has_key(val) and ucache[val]:
                    print "%s: %s" % (val, ucache[val])

            elif key == 'g':
                if gcache and gcache.has_key(val) and gcache[val]:
                    print "%s: %s" % (val, gcache[val])


        elif key in ('du', 'dg'):
            for workgroup in valid.keys():
                ucache = FreeNAS_UserCache(dir=workgroup)
                gcache = FreeNAS_GroupCache(dir=workgroup)
                ducache = FreeNAS_Directory_UserCache(dir=workgroup)
                dgcache = FreeNAS_Directory_GroupCache(dir=workgroup)

                if key == 'du':
                    if ducache and ducache.has_key(val) and ducache[val]:
                        print "%s: %s" % (val, ducache[val])

                elif key == 'dg':
                    if dgcache and dgcache.has_key(val) and dgcache[val]:
                        print "%s: %s" % (val, dgcache[val])