This page contains detailed information about how to manipulate various types of Active Directory objects. Keep in mind that all objects subclass ADObject.
Python object that represents any active directory object.
Adds current object to the specified group. group expects an ADGroup object.
ADsPath of Active Directory object (such as ‘LDAP://cn=me,...,dc=com‘
Appends values in list valuesToAppend to the specified multi-valued attribute. valuesToAppend can contain a single value or a list of multiple values.
Clears (removes) the specified LDAP attribute from the object. Identical to setting the attribute to None or [].
Distinguished Name (DN) of the object
Dumps object and all human-readable attributes to an xml document which is returned as a string.
Generates ADObject based on an existing ADSI com object
Generates ADObject based on distinguished name
Returns a list of allowed attributes for the particular object. These attributes may be defined, but are not guaranteed to be.
Returns the value of any allowable LDAP attribute of the specified object.
attribute – any schema-allowed LDAP attribute (case insensitive). The attribute does not need to be defined. always_return_list – if an attribute has a single value, this specifies whether to return only the
value or to return a list containing the single value. Similarly, if true, a query on an undefined attribute will return an empty list instead of a None object. If querying an attribute known to only contain at most one element, then it is easier to set to false. Otherwise, if querying a potentially multi-valued attribute, it is safest to leave at default.
source – either ‘LDAP’ or ‘GC’
Returns the domain to which the object belongs.
Returns a list of mandatory attributes for the particular object. These attributes are guaranteed to be defined.
Get the groups that this object is a member of
Returns a list of optional attributes for the particular object. These attributes may be defined, but are not guaranteed to be.
Returns uSNChanged as a single integer from the current domain controller
Returns a dictionary of settings stored within UserAccountControl. Expected keys for the dictionary are the same as keys in the ADS_USER_FLAG dictionary. Further information on these values can be found at http://msdn.microsoft.com/en-us/library/aa772300.aspx.
Object GUID of the object
Object GUID of the object
Check whether this object is a member of the given group
Moves the object to a new organizationalUnit.
new_ou_object expects a ADContainer object where the current object will be moved to.
Object representing the container in which this object lives
Returns the DN of the object’s parent container.
Prefixed CN (such as ‘cn=mycomputer’ or ‘ou=mycontainer’ of the object
Removes any values in list valuesToRemove from the specified multi-valued attribute.
Removes current object from the specified group. group expects an ADGroup object to which the current object belongs.
Renames the current object within its current organizationalUnit. new_name expects the new name of the object (just CN not prefixed CN or distinguishedName).
Sets a single setting in UserAccountControl.
UserFlag must be a value from ADS_USER_FLAG dictionary keys. More information can be found at http://msdn.microsoft.com/en-us/library/aa772300.aspx. newValue accepts boolean values
Get the SID of the Active Directory object
pyAD object type (user, computer, group, organizationalUnit, domain).
Creates and returns a new active directory user
Python class representing a computer object in Active Directory.
Accepts a list of pyAD objects or a single pyAD object and adds as members to the group.
Checks whether a pyAD object is a member of the group. check_member expects a pyAD object to be checked. recursive expects True/False which determines whether the group membership will be searched recursively.
Creates and returns a new group
Returns a list of group members. recursive - True/False. Determines whether to recursively traverse through nested groups. ignoreGroups - True/False. Determines whether or not to return an ADGroup objects in list or to ignore them.
Accepts a list of pyAD objects or a single pyAD object and removes these as members from the group.
Create a new computer object in the container
Create a new organizational unit in the container
Create a new group object in the container
Create a new user object in the container