當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。