本文整理汇总了Python中freenasUI.common.freenasldap.FreeNAS_ActiveDirectory.get_workgroup_name方法的典型用法代码示例。如果您正苦于以下问题:Python FreeNAS_ActiveDirectory.get_workgroup_name方法的具体用法?Python FreeNAS_ActiveDirectory.get_workgroup_name怎么用?Python FreeNAS_ActiveDirectory.get_workgroup_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类freenasUI.common.freenasldap.FreeNAS_ActiveDirectory
的用法示例。
在下文中一共展示了FreeNAS_ActiveDirectory.get_workgroup_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compare_netbios_names
# 需要导入模块: from freenasUI.common.freenasldap import FreeNAS_ActiveDirectory [as 别名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_ActiveDirectory import get_workgroup_name [as 别名]
binddn=binddn,
bindpw=bindpw,
errors=errors)
if ret is False:
raise forms.ValidationError("%s." % errors[0])
except FreeNAS_ActiveDirectory_Exception, e:
raise forms.ValidationError('%s.' % e)
args['binddn'] = binddn
args['bindpw'] = bindpw
else:
args['keytab_principal'] = ad_kerberos_principal.principal_name
args['keytab_file'] = '/etc/krb5.keytab'
workgroup = FreeNAS_ActiveDirectory.get_workgroup_name(**args)
if workgroup:
if compare_netbios_names(netbiosname, workgroup, None):
raise forms.ValidationError(
_("The NetBIOS name cannot be the same as the workgroup name!"
))
if netbiosname_b:
if compare_netbios_names(netbiosname_b, workgroup, None):
raise forms.ValidationError(
_("The NetBIOS name cannot be the same as the workgroup "
"name!"))
else:
log.warn("Unable to determine workgroup name")
if ssl in ("off", None):
示例2: clean
# 需要导入模块: from freenasUI.common.freenasldap import FreeNAS_ActiveDirectory [as 别名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_ActiveDirectory import get_workgroup_name [as 别名]
def clean(self):
cdata = self.cleaned_data
domain = cdata.get("ad_domainname")
bindname = cdata.get("ad_bindname")
binddn = "%[email protected]%s" % (bindname, domain)
bindpw = cdata.get("ad_bindpw")
site = cdata.get("ad_site")
netbiosname = cdata.get("ad_netbiosname_a")
netbiosname_b = cdata.get("ad_netbiosname_b")
ssl = cdata.get("ad_ssl")
certificate = cdata["ad_certificate"]
ad_kerberos_principal = cdata["ad_kerberos_principal"]
workgroup = None
if certificate:
certificate = certificate.get_certificate_path()
args = {
'domain': domain,
'site': site,
'ssl': ssl,
'certfile': certificate
}
if not cdata.get("ad_bindpw"):
bindpw = self.instance.ad_bindpw
cdata['ad_bindpw'] = bindpw
if cdata.get("ad_enable") is False:
return cdata
if not ad_kerberos_principal:
if not bindname:
raise forms.ValidationError("No domain account name specified")
if not bindpw:
raise forms.ValidationError("No domain account password specified")
try:
FreeNAS_ActiveDirectory.validate_credentials(
domain,
site=site,
ssl=ssl,
certfile=certificate,
binddn=binddn,
bindpw=bindpw
)
except LDAPError as e:
# LDAPError is dumb, it returns a list with one element for goodness knows what reason
e = e[0]
error = []
desc = e.get('desc')
info = e.get('info')
if desc:
error.append(desc)
if info:
error.append(info)
if error:
error = ', '.join(error)
else:
error = str(e)
raise forms.ValidationError("{0}".format(error))
except Exception as e:
raise forms.ValidationError('{0}.'.format(str(e)))
args['binddn'] = binddn
args['bindpw'] = bindpw
else:
args['keytab_principal'] = ad_kerberos_principal.principal_name
args['keytab_file'] = '/etc/krb5.keytab'
try:
workgroup = FreeNAS_ActiveDirectory.get_workgroup_name(**args)
except Exception as e:
raise forms.ValidationError(e)
if workgroup:
if compare_netbios_names(netbiosname, workgroup, None):
raise forms.ValidationError(_(
"The NetBIOS name cannot be the same as the workgroup name!"
))
if netbiosname_b:
if compare_netbios_names(netbiosname_b, workgroup, None):
raise forms.ValidationError(_(
"The NetBIOS name cannot be the same as the workgroup "
"name!"
))
else:
log.warn("Unable to determine workgroup name")
if ssl in ("off", None):
return cdata
if not certificate:
raise forms.ValidationError(
"SSL/TLS specified without certificate")
#.........这里部分代码省略.........