class adUtils - Wengex/PyADLdap GitHub Wiki
Class with useful tools to facilitate using the framework. This class is inherited from adLDAP. His methods, attributes and properties can be called from the primary instance.
###class ObjectNotHaveEnable(Exception) Exception to check if object have a Enable method
###class MultipleResults(Exception) Exception to raise when exists multiple results to call adObjs.get() method
###class ObjectNotExist(Exception) Exception to raise when there is not result to call adObjs.get() or adObjs.filter() methods.
###class NotDNDefinied(Exception) Exception to raise when there is not DN attribute definied when a new object is saved.
###class EmptyAttrNewObj(Exception) Exception to raise when there is not Attribute definied when a new object is saved.
###class NotUACValueSelected(Exception) Exception to raise when not User Account Control Value is selected from acControl dict attribute
###acControl Dict attribute to relate a Human Description with the user account control flags
###littleEndian(self,hex) Method like class to calculate the littleEndian from hexadecimal value. This method is called from self.getTextSid() method.
- Params:
- (string)hex : Hexadecimal value
- Return: (string) Text SID
- Attributes: None
###getTextSID(self,binsid) Method like class to get a SID value from binary sid attribute
- Params:
- (string)binsid: binary sid data
- Return: (string) Text SID
- Attributes: None
###accountControl(self,options) Method to calculate useraccountcontrol attribute from acControl dict keys.
- Params:
- (list)options: Options values list from acControl attribute keys
- Return: (int) useraccountconltrol value
- Attributes: None
###setQuery(self,operator='&',**fields) Method to generate ldap query sentences from **fields param dict
This method generate "AND" global sentence but also can generate NOT, LESS That, MORE That, and Equal subsentences using follow suffix:
attrubute="value" -> (attribute=value)
attribute__not="value" -> (!(attribute=value))
attribute__gt="value" -> (attribute>value)
attribute__lt="value" -> (attribute<value)
attribute__gt__not="value" -> (!(attribute>value))
If list value is used then method generate multiple subsentences:
attribute=["value1","value2","value3"] -> (attribute=value1)(attribute=value2)(attribute=value3)
attribute__not=["value1","value2","value3"] -> (!(attribute=value1))(!(attribute=value2))(!(attribute=value3))
- Params:
- (char)operator: set the operator global sentence. & -> AND, | -> OR. Default is AND value
- (bool)is_disable: this option create (userAccountControl:1.2.840.113556.1.4.803:=2) subsentence
- (dict)**fields: methods parameters
- Return: (string) ldap query sentence
- Attributes: None