本文整理汇总了Python中activedirectory.core.creds.Creds.principal方法的典型用法代码示例。如果您正苦于以下问题:Python Creds.principal方法的具体用法?Python Creds.principal怎么用?Python Creds.principal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类activedirectory.core.creds.Creds
的用法示例。
在下文中一共展示了Creds.principal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_acquire_keytab
# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import principal [as 别名]
def test_acquire_keytab(self, conf):
conf.require(ad_user=True)
domain = conf.domain()
creds = ADCreds(domain)
principal = conf.ad_user_account()
password = conf.ad_user_password()
creds.acquire(principal, password)
os.environ['PATH'] = '/usr/kerberos/sbin:/usr/kerberos/bin:%s' % \
os.environ['PATH']
fullprinc = creds.principal()
child = pexpect.spawn('kvno %s' % fullprinc)
child.expect('kvno =')
kvno = int(child.readline())
child.expect(pexpect.EOF)
child = pexpect.spawn('ktutil')
child.expect('ktutil:')
child.sendline('addent -password -p %s -k %d -e rc4-hmac' %
(fullprinc, kvno))
child.expect('Password for.*:')
child.sendline(password)
child.expect('ktutil:')
keytab = conf.tempfile(remove=True)
child.sendline('wkt %s' % keytab)
child.expect('ktutil:')
child.sendline('quit')
child.expect(pexpect.EOF)
creds.release()
creds.acquire(principal, keytab=keytab)
child = pexpect.spawn('klist')
pattern = '.*krbtgt/%[email protected]%s' % (domain.upper(), domain.upper())
assert child.expect([pattern]) == 0
示例2: test_load
# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import principal [as 别名]
def test_load(self, conf):
conf.require(ad_user=True)
domain = conf.domain().upper()
principal = '%[email protected]%s' % (conf.ad_user_account(), domain)
conf.acquire_credentials(principal, conf.ad_user_password())
creds = ADCreds(domain)
creds.load()
assert creds.principal().lower() == principal.lower()
ccache, princ, creds = conf.list_credentials()
assert princ.lower() == principal.lower()
assert len(creds) > 0
assert creds[0] == 'krbtgt/%[email protected]%s' % (domain, domain)
示例3: test_acquire_password
# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import principal [as 别名]
def test_acquire_password(self, conf):
conf.require(ad_user=True)
domain = conf.domain()
creds = ADCreds(domain)
principal = conf.ad_user_account()
password = conf.ad_user_password()
creds.acquire(principal, password)
principal = '%[email protected]%s' % (principal, domain)
assert creds.principal().lower() == principal.lower()
child = pexpect.spawn('klist')
pattern = '.*krbtgt/%[email protected]%s' % (domain.upper(), domain.upper())
assert child.expect([pattern]) == 0