Ejemplo n.º 1
0
connection into the query function. You might want to do this if
you needed to authenticate the connection or if you were performing
a number of queries and wanted to avoid the overhead of repeated
connection-building.
"""
import win32api
import win32con
import win32cred
from active_directory import core

username, domain = win32cred.CredUIParseUserName (win32api.GetUserNameEx (win32con.NameDnsDomain))
username, password, save = win32cred.CredUIPromptForCredentials (
  domain, 0, username,
  None, True, 0, None
)
connection = core.connect (username, password)
for obj in core.query (
  core.query_string ("objectCategory=organizationalUnit"),
  connection=connection
):
  print obj

print

"""When you create a specific connection you can pass various flags
through as the adsi_flags parameter. The possible flags are documented
on MSDN: http://msdn.microsoft.com/en-us/library/aa772247%28v=vs.85%29.aspx
and are presented via the AUTHENTICATION_TYPES enum from the constants
module. For example, using a fast bind can speed up simple operations.
"""
from active_directory import core
Ejemplo n.º 2
0
"""By default, the active_directory package assumes that you're
using standard Windows authentication to bind to AD. But there
are two other options: anonymous authentication; and user/password
sign-on. If you need either of those, you'll have to create a
credentials object and pass it around to any function which needs
to bind or query AD.
"""

"""Query AD as an anonymous user
"""
from active_directory import core, credentials

qs = core.query_string (base="LDAP://sibelius")
for i in core.query (query_string=qs, connection=core.connect (cred=credentials.Anonymous)):
  print i