Bases: object
Bases: keystone.common.ldap.core.BaseLdap
Emulates boolean ‘enabled’ attribute if turned on.
Creates groupOfNames holding all enabled objects of this class, all missing objects are considered disabled.
Options:
Where ${name}s is the plural of self.options_name (‘users’ or ‘tenants’), ${tree_dn} is self.tree_dn.
Bases: object
Convert LDAP search result to Python types used by OpenStack.
Each result tuple is of the form (dn, attrs), where dn is a string containing the DN (distinguished name) of the entry, and attrs is a dictionary containing the attributes associated with the entry. The keys of attrs are strings, and the associated values are lists of strings.
OpenStack wants to use Python types of its choosing. Strings will be unicode, truth values boolean, whole numbers int’s, etc. DN’s will also be decoded from UTF-8 to unicode.
Parameters: | ldap_result – LDAP search result |
---|---|
Returns: | list of 2-tuples containing (dn, attrs) where dn is unicode and attrs is a dict whose values are type converted to OpenStack preferred types. |
Returns True if and only if the descendant_dn is under the dn.
Parameters: |
|
---|
Returns True if and only if the AVAs are equal.
When comparing AVAs, the equality matching rule for the attribute type should be taken into consideration. For simplicity, this implementation does a case-insensitive comparison.
Note that this function uses prep_case_insenstive so the limitations of that function apply here.
Returns True if and only if the DNs are equal.
Two DNs are equal if they’ve got the same number of RDNs and if the RDNs are the same at each position. See RFC4517.
Note that this function uses is_rdn_equal to compare RDNs so the limitations of that function apply here.
Parameters: |
|
---|
Returns True if and only if the RDNs are equal.
Note that this function uses is_ava_value_equal to compare AVAs so the limitations of that function apply here.
Convert an LDAP formatted value to Python type used by OpenStack.
Virtually all LDAP values are stored as UTF-8 encoded strings. OpenStack prefers values which are Python types, e.g. unicode, boolean, integer, etc.
Parameters: | val – LDAP formatted value |
---|---|
Returns: | val converted to preferred Python type |
Prepare a string for case-insensitive comparison.
This is defined in RFC4518. For simplicity, all this function does is lowercase all the characters, strip leading and trailing whitespace, and compress sequences of spaces to a single space.
Type convert a Python value to a type accepted by LDAP (unicode).
The LDAP API only accepts strings for values therefore convert the value’s type to a unicode string. A subsequent type conversion will encode the unicode as UTF-8 as required by the python-ldap API, but for now we just want a string representation of the value.
Parameters: | val – The value to convert to a LDAP string representation |
---|---|
Returns: | unicode string representation of value. |
Decode a from UTF-8 into unicode.
If the value is a binary string assume it’s UTF-8 encoded and decode it into a unicode string. Otherwise convert the value from its type into a unicode string.
Parameters: | value – value to be returned as unicode |
---|---|
Returns: | value as unicode |
Raises: | UnicodeDecodeError for invalid UTF-8 encoding |
Encode a basestring to UTF-8.
If the string is unicode encode it to UTF-8, if the string is str then assume it’s already encoded. Otherwise raise a TypeError.
Parameters: | value – A basestring |
---|---|
Returns: | UTF-8 encoded version of value |
Raises: | TypeError if value is not basestring |