aduser Module

class aduser.ADuser(username, ad_obj=None, attributes=None)[source]

Bases: object

An Active Directory-backed user-representation object.

Parameters:
  • username – sAMAccountName of the user.
  • ad_obj (mldap2) – connected object.
  • attributes – Dictionary to initiate with.
Example:
>>> u = ADuser("wimpy", attributes={'mail': 'wimpy@wimpy.org',
                                    'initial': 'w'})

Note

__setattr__() is defined, so attribute changes
will be made live if an ad_obj is provided.
attr_map = {'distinguishedName': 'distinguishedName', 'username': 'sAMAccountName', 'firstname': 'givenName', 'lastname': 'sn', 'initial': 'initials', 'idno': 'employeeNumber', 'email': 'mail'}

attr_map should be moved. It documents a more general mapping to specific AD attributes.

commit()[source]

commit back attribute changes to active directory .. note:: deprecated now that __setattr__ has been added.

get_uac()[source]

Return the UAC object representing this user.

refresh()[source]

Refresh all attributes from Active Directory.

replace(attr, value)[source]

Replace a given attribute with a new value and commit any changes immediately.

update_from(other)[source]

update user attributes from another user type.

Note

Not implemented.

writable_attributes = ['mail', 'givenName', 'initials', 'sn', 'employeeNumber', 'userPrincipalName', 'sAMAccountName']

writable_attributes are those that are allowed to be written back to AD when using the commit() function.