pyncli.ldap

pyncli.ldap.admexept

AdminException

AdminException(self, value, code=None)

Root package exception class.

Args: value (str): Description of the exception.

NotEnoughParams

NotEnoughParams(self, value, code=None)

Exception class called in case of lack of necessary parameters in the constructor or method call.

Args: value (str): Description of the exception.

EmptyParam

EmptyParam(self, value, code=None)

Exception class called when a method is called with an empty parameter.

Args: value (str): Description of the exception.

WrongParam

WrongParam(self, value, code=None)

The exception class that is called when the method is called as a parameter of an invalid type or value.

Args: value (str): Description of the exception.

TooLong

TooLong(self, value, code=None)

Exception class called when the method is called with an invalid length parameter.

Args: value (str): Description of the exception.

ConnectionFailure

ConnectionFailure(self, value, code=None)

Exception class called when it is impossible to connect to the specified server.

Args: value (str): Description of the exception.

OperationFailure

OperationFailure(self, value, code=None)

Exception class called when it is impossible to perform the specified operation.

Args: value (str): Description of the exception.

NotFound

NotFound(self, value, code=None)

Exception class called in case of problems with the search.

Called when the desired object was not found.

Args: value (str): Description of the exception.

pyncli.ldap.operate2

A module that implements the admin class for working with LDAP.

admin

admin(self, ldap_admin, admin_pwd, ldap_server_list)

Class for administrative operations

pyncli.ldap.protogroup

protogroup

protogroup(self, name, org_unit, **kwargs)

base group class

pyncli.ldap.group

CleanSetAttrMeta

CleanSetAttrMeta(self, /, *args, **kwargs)

Metaclass to change setattr method

group

group(self, name, org_unit='ou=test_ou,dc=example,dc=com', description='', **kwargs)

common group class

pyncli.ldap.protoou

CleanSetAttrMeta

CleanSetAttrMeta(self, /, *args, **kwargs)

Metaclass to change setattr method

protoou

protoou(self, name, org_unit, **kwargs)

base Organisational Unit class

pyncli.ldap.ou

ou

ou(self, name, org_unit='ou=test_ou,dc=example,dc=com', description='', **kwargs)

Common Organizational Utit class

pyncli.ldap.protouser

protouser

protouser(self, login, **kwargs)

Base user class

pyncli.ldap.user

CleanSetAttrMeta

CleanSetAttrMeta(self, /, *args, **kwargs)

Metaclass to change setattr method

user

user(self, login, uid='', org_unit='OU=test,DC=example,DC=com', surname='', first_name='', middle_name='', company='', department='', division='', position='', mail='', mobile='', other_mailbox='0', other_mobile='0', comment='', employee_type='', acc_control=[<uac.NORMAL_ACCOUNT: 512>, <uac.ACCOUNTDISABLE: 2>], description='', principal_name='', **kwargs)

Common user class

uac

uac(self, /, *args, **kwargs)

userAccountControl Enumerator class

ACCOUNTDISABLE

userAccountControl Enumerator class

DONT_EXPIRE_PASSWORD

userAccountControl Enumerator class

DONT_REQ_PREAUTH

userAccountControl Enumerator class

ENCRYPTED_TEXT_PWD_ALLOWED

userAccountControl Enumerator class

hex

Get hex representation of uac instance

Returns: (str): hex representation of uac instance

HOMEDIR_REQUIRED

userAccountControl Enumerator class

INTERDOMAIN_TRUST_ACCOUNT

userAccountControl Enumerator class

LOCKOUT

userAccountControl Enumerator class

MNS_LOGON_ACCOUNT

userAccountControl Enumerator class

NORMAL_ACCOUNT

userAccountControl Enumerator class

NOT_DELEGATED

userAccountControl Enumerator class

PASSWD_CANT_CHANGE

userAccountControl Enumerator class

PASSWD_NOTREQD

userAccountControl Enumerator class

PASSWORD_EXPIRED

userAccountControl Enumerator class

SCRIPT

userAccountControl Enumerator class

SERVER_TRUST_ACCOUNT

userAccountControl Enumerator class

SMARTCARD_REQUIRED

userAccountControl Enumerator class

TEMP_DUPLICATE_ACCOUNT

userAccountControl Enumerator class

TRUSTED_FOR_DELEGATION

userAccountControl Enumerator class

TRUSTED_TO_AUTH_FOR_DELEGATION

userAccountControl Enumerator class

USE_DES_KEY_ONLY

userAccountControl Enumerator class

val

Get value of uac instance

Returns: (int): value of uac instance

WORKSTATION_TRUST_ACCOUNT

userAccountControl Enumerator class

get_status

uac.get_status(hex_status_code)

Get a list of userAccountControl flags names.

Args: hex_status_code (str): userAccountControl hex value

Returns: (list): userAccountControl flags names.

get_uac

uac.get_uac(hex_status_code)

Get a list of userAccountControl flags.

Args: hex_status_code (str): userAccountControl hex value

Returns: (list): userAccountControl flags.

get_control

uac.get_control(flag_list)

Get userAccountControl value.

Args: flag_list (list): userAccountControl list

Returns: (list): userAccountControl hex value or False.

pyncli.ldap.utill

Module with auxiliary functions.

download_file

download_file(url, local_path, user, pwd)

Download file

Downloads a file with basic authentication.

Args: url (str): URL local_path (str): file full name user (str): user name pwd (str): password

Returns: (str): file full name

Raises: ConnectionFailure: connection failure

upload_file

upload_file(url, data, login, pwd)

Upload file

Uploads a file with basic authentication.

Args: url (str): URL data (str): string or buffer to load login (str): user name pwd (str): password

Returns: (str): file full name

Raises: OperationFailure: operation failure

mailto

mailto(msg_from, msg_to_list, smpt, subject, text)

Simple mailto function

Sends a message to one or a group of recipients.

Args: msg_from (str): From whom msg_to_list (list): List of email recipients. smpt (str): SMTP server name or IP subject (str): subject of the message text (str): text of the message

Raises: ConnectionFailure: connection failure

trim

trim(text)

Removes extra spaces from text.

Args: text (str): text

Returns: (str): processed text

trim_low

trim_low(text)

Removes extra spaces from text and set it to lower case.

Args: text (str): text

Returns: (str): processed text

split_names

split_names(fullname)

Splits user fullname by surname, first name and middle name.

Args: fullname (str): full name (The first word is considered the surname, the second first name, all the rest go to the middle name. This is the Russian name record format.)

Returns: (dict): Dictionary with surname, first name and middle name as values.

date_str_to_generalize_time

date_str_to_generalize_time(date_str)

Converts date in string format to date in generalized time format.

Args: date_str (str): Date string in formats %Y-%m-%d, %Y/%m/%d or %d.%m.%Y

Returns: (str): Date in generalized time format.

Note: Time zone information is not supported.

is_generalized_time

is_generalized_time(date_str)

Checks is this string look like generalized time.

Args: date_str (str): Date string

Returns: (bool): True if input string is generalized time.

Note: Time zone information is not supported.

generalized_time_to_datetime

generalized_time_to_datetime(gen_time)

Converts date in generalized time format to datetime

Args: gen_time (str): Date string in generalized time format

Returns: (datetime): datetime object

Note: Time zone information is not supported.

datetime_to_generalized_time

datetime_to_generalized_time(date_time)

Converts datetime to generalized time format.

Args: date_time (datetime): datetime object

Returns: (str): Date in generalized time format.

Note: Time zone information is not supported.