本文整理汇总了Python中activedirectory.core.creds.Creds类的典型用法代码示例。如果您正苦于以下问题:Python Creds类的具体用法?Python Creds怎么用?Python Creds使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Creds类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_acquire_multi
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
示例2: test_add
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)
示例3: test_search
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
示例4: test_delete
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)
示例5: test_naming_contexts
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
示例6: test_search_schema
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
示例7: test_search
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
示例8: test_forest
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()
示例9: test_search_configuration
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
示例10: test_search_server
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
示例11: test_domains
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()
示例12: test_search_all_domains
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
示例13: test_modify
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)
示例14: test_load
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)
示例15: test_acquire_password
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