本文整理汇总了Python中freenasUI.common.freenasldap.FreeNAS_ActiveDirectory.get_domains方法的典型用法代码示例。如果您正苦于以下问题:Python FreeNAS_ActiveDirectory.get_domains方法的具体用法?Python FreeNAS_ActiveDirectory.get_domains怎么用?Python FreeNAS_ActiveDirectory.get_domains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类freenasUI.common.freenasldap.FreeNAS_ActiveDirectory
的用法示例。
在下文中一共展示了FreeNAS_ActiveDirectory.get_domains方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _cache_keys_ActiveDirectory
# 需要导入模块: from freenasUI.common.freenasldap import FreeNAS_ActiveDirectory [as 别名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_ActiveDirectory import get_domains [as 别名]
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
示例2: _cache_rawdump_ActiveDirectory
# 需要导入模块: from freenasUI.common.freenasldap import FreeNAS_ActiveDirectory [as 别名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_ActiveDirectory import get_domains [as 别名]
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])
示例3: directoryservice
# 需要导入模块: from freenasUI.common.freenasldap import FreeNAS_ActiveDirectory [as 别名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_ActiveDirectory import get_domains [as 别名]
def directoryservice(self, name):
"""Temporary rapper to serialize DS connectors"""
if name == 'AD':
ds = FreeNAS_ActiveDirectory(flags=FLAGS_DBINIT)
workgroups = []
domains = ds.get_domains()
for d in domains:
if 'nETBIOSName' in d:
netbiosname = d['nETBIOSName']
workgroups.append(netbiosname)
ds.workgroups = workgroups
elif name == 'LDAP':
ds = FreeNAS_LDAP(flags=FLAGS_DBINIT)
else:
raise ValueError('Unknown ds name {0}'.format(name))
data = {}
for i in (
'netbiosname', 'keytab_file', 'keytab_principal', 'domainname',
'use_default_domain', 'dchost', 'basedn', 'binddn', 'bindpw',
'userdn', 'groupdn', 'ssl', 'certfile', 'id',
'ad_idmap_backend', 'ds_type',
'krb_realm', 'krbname', 'kpwdname',
'krb_kdc', 'krb_admin_server', 'krb_kpasswd_server',
'workgroups'
):
if hasattr(ds, i):
data[i] = getattr(ds, i)
return data
示例4: _cache_count_ActiveDirectory
# 需要导入模块: from freenasUI.common.freenasldap import FreeNAS_ActiveDirectory [as 别名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_ActiveDirectory import get_domains [as 别名]
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"
示例5: _cache_check_ActiveDirectory
# 需要导入模块: from freenasUI.common.freenasldap import FreeNAS_ActiveDirectory [as 别名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_ActiveDirectory import get_domains [as 别名]
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])