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


Python Creds.acquire方法代码示例

本文整理汇总了Python中activedirectory.core.creds.Creds.acquire方法的典型用法代码示例。如果您正苦于以下问题:Python Creds.acquire方法的具体用法?Python Creds.acquire怎么用?Python Creds.acquire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在activedirectory.core.creds.Creds的用法示例。


在下文中一共展示了Creds.acquire方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_acquire_multi

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [as 别名]
 def test_acquire_multi(self, conf):
     conf.require(ad_user=True)
     domain = conf.domain()
     principal = conf.ad_user_account()
     password = conf.ad_user_password()
     creds1 = ADCreds(domain)
     creds1.acquire(principal, password)
     ccache1 = creds1._ccache_name()
     config1 = creds1._config_name()
     assert ccache1 == os.environ['KRB5CCNAME']
     assert config1 == os.environ['KRB5_CONFIG']
     creds2 = ADCreds(domain)
     creds2.acquire(principal, password)
     ccache2 = creds2._ccache_name()
     config2 = creds2._config_name()
     assert ccache2 == os.environ['KRB5CCNAME']
     assert config2 == os.environ['KRB5_CONFIG']
     assert ccache1 != ccache2
     assert config1 != config2
     activate(creds1)
     assert os.environ['KRB5CCNAME'] == ccache1
     assert os.environ['KRB5_CONFIG'] == config1
     activate(creds2)
     assert os.environ['KRB5CCNAME'] == ccache2
     assert os.environ['KRB5_CONFIG'] == config2
开发者ID:theatlantic,项目名称:python-active-directory,代码行数:27,代码来源:test_creds.py

示例2: test_acquire_keytab

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [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

示例3: test_add

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [as 别名]
 def test_add(self):
     self.require(ad_admin=True)
     domain = self.domain()
     creds = Creds(domain)
     creds.acquire(self.ad_admin_account(), self.ad_admin_password())
     activate(creds)
     client = Client(domain)
     user = self._create_user(client, 'test-usr')
     self._delete_obj(client, user)
开发者ID:mosutw,项目名称:python-active-directory,代码行数:11,代码来源:test_client.py

示例4: test_search

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [as 别名]
 def test_search(self):
     self.require(ad_user=True)
     domain = self.domain()
     creds = Creds(domain)
     creds.acquire(self.ad_user_account(), self.ad_user_password())
     activate(creds)
     client = Client(domain)
     result = client.search('(objectClass=user)')
     assert len(result) > 1
开发者ID:mosutw,项目名称:python-active-directory,代码行数:11,代码来源:test_client.py

示例5: test_delete

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [as 别名]
 def test_delete(self, conf):
     conf.require(ad_admin=True)
     domain = conf.domain()
     creds = Creds(domain)
     creds.acquire(conf.ad_admin_account(), conf.ad_admin_password())
     activate(creds)
     client = Client(domain)
     dn = utils.create_user(client, 'test-usr')
     client.delete(dn)
开发者ID:theatlantic,项目名称:python-active-directory,代码行数:11,代码来源:test_client.py

示例6: test_naming_contexts

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [as 别名]
 def test_naming_contexts(self, conf):
     conf.require(ad_user=True)
     domain = conf.domain()
     creds = Creds(domain)
     creds.acquire(conf.ad_user_account(), conf.ad_user_password())
     activate(creds)
     client = Client(domain)
     naming_contexts = client.naming_contexts()
     assert len(naming_contexts) >= 3
开发者ID:theatlantic,项目名称:python-active-directory,代码行数:11,代码来源:test_client.py

示例7: test_search_schema

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [as 别名]
 def test_search_schema(self):
     self.require(ad_user=True)
     domain = self.domain()
     creds = Creds(domain)
     creds.acquire(self.ad_user_account(), self.ad_user_password())
     activate(creds)
     client = Client(domain)
     base = client.schema_base()
     result = client.search('(objectClass=*)', base=base, scope='base')
     assert len(result) == 1
开发者ID:mosutw,项目名称:python-active-directory,代码行数:12,代码来源:test_client.py

示例8: test_search

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [as 别名]
 def test_search(self, conf):
     pytest.skip('test disabled: hanging')
     conf.require(ad_user=True)
     domain = conf.domain()
     creds = Creds(domain)
     creds.acquire(conf.ad_user_account(), conf.ad_user_password())
     activate(creds)
     client = Client(domain)
     result = client.search('(objectClass=user)')
     assert len(result) > 1
开发者ID:theatlantic,项目名称:python-active-directory,代码行数:12,代码来源:test_client.py

示例9: test_forest

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [as 别名]
 def test_forest(self, conf):
     conf.require(ad_user=True)
     domain = conf.domain()
     creds = Creds(domain)
     creds.acquire(conf.ad_user_account(), conf.ad_user_password())
     activate(creds)
     client = Client(domain)
     forest = client.forest()
     assert forest
     assert forest.isupper()
开发者ID:theatlantic,项目名称:python-active-directory,代码行数:12,代码来源:test_client.py

示例10: test_search_configuration

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [as 别名]
 def test_search_configuration(self, conf):
     conf.require(ad_user=True)
     domain = conf.domain()
     creds = Creds(domain)
     creds.acquire(conf.ad_user_account(), conf.ad_user_password())
     activate(creds)
     client = Client(domain)
     base = client.configuration_base()
     result = client.search('(objectClass=*)', base=base, scope='base')
     assert len(result) == 1
开发者ID:theatlantic,项目名称:python-active-directory,代码行数:12,代码来源:test_client.py

示例11: test_search_server

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [as 别名]
 def test_search_server(self, conf):
     conf.require(ad_user=True)
     domain = conf.domain()
     creds = Creds(domain)
     creds.acquire(conf.ad_user_account(), conf.ad_user_password())
     activate(creds)
     locator = Locator()
     server = locator.locate(domain)
     client = Client(domain)
     result = client.search('(objectClass=user)', server=server)
     assert len(result) > 1
开发者ID:theatlantic,项目名称:python-active-directory,代码行数:13,代码来源:test_client.py

示例12: test_domains

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [as 别名]
 def test_domains(self, conf):
     conf.require(ad_user=True)
     domain = conf.domain()
     creds = Creds(domain)
     creds.acquire(conf.ad_user_account(), conf.ad_user_password())
     activate(creds)
     client = Client(domain)
     domains = client.domains()
     for domain in domains:
         assert domain
         assert domain.isupper()
开发者ID:theatlantic,项目名称:python-active-directory,代码行数:13,代码来源:test_client.py

示例13: test_acquire_password

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [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

示例14: test_search_all_domains

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [as 别名]
 def test_search_all_domains(self, conf):
     conf.require(ad_user=True)
     domain = conf.domain()
     creds = Creds(domain)
     creds.acquire(conf.ad_user_account(), conf.ad_user_password())
     activate(creds)
     client = Client(domain)
     domains = client.domains()
     for domain in domains:
         base = client.dn_from_domain_name(domain)
         result = client.search('(objectClass=*)', base=base, scope='base')
         assert len(result) == 1
开发者ID:theatlantic,项目名称:python-active-directory,代码行数:14,代码来源:test_client.py

示例15: test_modify

# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import acquire [as 别名]
 def test_modify(self, conf):
     conf.require(ad_admin=True)
     domain = conf.domain()
     creds = Creds(domain)
     creds.acquire(conf.ad_admin_account(), conf.ad_admin_password())
     activate(creds)
     client = Client(domain)
     user = utils.create_user(client, 'test-usr')
     mods = []
     mods.append(('replace', 'sAMAccountName', ['test-usr-2']))
     client.modify(user, mods)
     delete_obj(client, user)
开发者ID:theatlantic,项目名称:python-active-directory,代码行数:14,代码来源:test_client.py


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