Skip to main content
Introduction
------------

pyad is a python library designed to provide a simple, object oriented interface to Active Directory through ADSI on the Windows platform. pyad requires pywin32, available at http://sourceforge.net/projects/pywin32.

pyad is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

A copy of the GNU General Public License is available at <http://www.gnu.org/licenses/>.

Basics
------

Active Directory objects are represented by standard python objects. There are classes for all major types of Active Directory objects: ADComputer, ADContainer, ADDomain, ADGroup, ADUser, all of which inherit from ADObject. It is possible to connect to objects via CN, DN, and GUID. Example:

import pyad
u = pyad.aduser.ADUser.from_cn("user1")
c = pyad.adcomputer.ADComputer.from_dn("cn=WS1,ou=Workstations,dc=domain,dc=com")
g = pyad.adgroup.ADGroup.from_cn("group1")

It is possible to read attribute values in two ways.

print u.displayName
print u.get_attribute("displayName")

Attributes can be set by calling clear_attribute, update_attribute, update_attributes, append_to_attribute, and remove_from_attribute. Example:

u.update_attribute("displayName", "new value")

There are other helper methods available for managing attributes. We provide further examples below for common actions for each object type.

Group Examples
--------------

1. Finding group members:

for object in g.get_members(recursive=False):
print object

2. Adding an object to a group:

g.add_members(u)
or
u.add_to_group(g)

3. Set group scope:

g.set_group_scope("UNIVERSAL")

User Examples
-------------

1. Set password:

u.set_password("new_plaintext_password")

2. Force password change on login:

u.force_pwd_change_on_login()

Container Examples
------------------

1. Find all objects in an OU:

ou = pyad.adcontainer.ADContainer.from_dn("OU=Workstations,DC=company,DC=com")
for obj in ou.get_children():
print obj

2. Recursively find all computers below a certain OU:

for c in ou.get_children(recursive=True, filter=[pyad.adcomputer.ADComputer]):
print c

Creating Objects
----------------

It is possible to create objects through pyad. Example:

ou = pyad.adcontainer.ADContainer.from_dn("OU=Workstations,DC=company,DC=com")
c = pyad.adcomputer.ADComputer.create(
name = 'myworkstation2',
container_object = ou,
enable = True,
optional_attributes = dict(
description = "newly created computer"
)
)

Querying
--------

It is also possible to make queries to find objects. Example:

q = pyad.adquery.ADQuery()
q.execute_query(
attributes = ['distinguishedname', 'description'],
where_clause = "cn like 'ws%'",
base_dn = "dc=company,dc=com"
)
for r in q.get_results():
print r['distinguishedname']

Metadata

Release files for pyad 0.4.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyad 0.4.9
File Size Uploaded Provenance Actions
pyad.0.4.9.tar.gz 253.4 kB Without provenance Details for pyad.0.4.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyad 0.4.9
File Interpreter ABI Platform Actions
pyad-0.4.9-py2.7.egg Legacy Egg format - - Details for pyad-0.4.9-py2.7.egg

Total release size: 297.9 kB

Release files / pyad.0.4.9.tar.gz

Download URL pyad.0.4.9.tar.gz
Size 253.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4e8acdef75cdec4b8f061ee69c911c2cf2b151a3ae35b0e0ada3d402b66024bd
BLAKE2b-256 checksum
How to use checksums
2ad95beeab88ad803f8ed120d41260de6604d83cbe74405552a1a1e97d9cbfef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyad-0.4.9-py2.7.egg

Download URL pyad-0.4.9-py2.7.egg
Size 44.5 kB
Tags Egg
SHA-256 checksum
How to use checksums
3c4c293837ef8e3061d610a3b45ce1a74f7bc33b469d724b91d08f14f42089cd
BLAKE2b-256 checksum
How to use checksums
e9947c93e74b1b8e983b14823effba382488412eab71484adff9856eac2c5a23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyad 0.4.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page