当前位置: 首页>>代码示例>>Python>>正文


Python Creds.principal方法代码示例

本文整理汇总了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
开发者ID:theatlantic,项目名称:python-active-directory,代码行数:33,代码来源:test_creds.py

示例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)
开发者ID:theatlantic,项目名称:python-active-directory,代码行数:14,代码来源:test_creds.py

示例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
开发者ID:theatlantic,项目名称:python-active-directory,代码行数:14,代码来源:test_creds.py


注:本文中的activedirectory.core.creds.Creds.principal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。