コード例 #1
0
from __future__ import print_function
from activedirectory import Client, Creds, Locator, activate

domain = 'freeadi.org'
user = '******'
password = '******'

levels = {
    '0': 'windows 2000',
    '1': 'windows 2003 interim',
    '2': 'windows 2003'
}

creds = Creds(domain)
creds.acquire(user, password)
activate(creds)

locator = Locator()
server = locator.locate(domain)

client = Client(domain)
result = client.search(base='', scope='base', server=server)
assert len(result) == 1
dn, attrs = result[0]
level = attrs['forestFunctionality'][0]
level = levels.get(level, 'unknown')
print('Forest functionality level: %s' % level)
コード例 #2
0
from activedirectory import Client, Creds, Locator, activate

domain = 'freeadi.org'
user = '******'
password = '******'

creds = Creds(domain)
creds.acquire(user, password)
activate(creds)

locator = Locator()
pdc = locator.locate(domain, role='pdc')

client = Client(domain)
users = client.search('(objectClass=user)', server=pdc)
for dn,attrs in users:
    name = attrs['sAMAccountName'][0]
    print '-> %s' % name
コード例 #3
0
from activedirectory import Client, Creds, Locator, activate

domain = 'freeadi.org'
user = '******'
password = '******'

levels = \
{
    '0': 'windows 2000',
    '1': 'windows 2003 interim',
    '2': 'windows 2003'
}

creds = Creds(domain)
creds.acquire(user, password)
activate(creds)

locator = Locator()
server = locator.locate(domain)

client = Client(domain)
result = client.search(base='', scope='base', server=server)
assert len(result) == 1
dn, attrs = result[0]
level = attrs['forestFunctionality'][0]
level = levels.get(level, 'unknown')
print 'Forest functionality level: %s' % level