summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipaserver/ipaldap.py38
-rw-r--r--ipaserver/plugins/ldap2.py38
2 files changed, 40 insertions, 36 deletions
diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py
index 3e115e3b..20da4418 100644
--- a/ipaserver/ipaldap.py
+++ b/ipaserver/ipaldap.py
@@ -902,6 +902,44 @@ class LDAPConnection(object):
obj = self.schema.get_obj(_ldap.schema.AttributeType, attr)
return obj and obj.single_value
+ def normalize_dn(self, dn):
+ """Override to normalize all DNs passed to LDAPConnection methods"""
+ assert isinstance(dn, DN)
+ return dn
+
+ def make_dn_from_attr(self, attr, value, parent_dn=None):
+ """
+ Make distinguished name from attribute.
+
+ Keyword arguments:
+ parent_dn -- DN of the parent entry (default '')
+ """
+ if parent_dn is None:
+ parent_dn = DN()
+ parent_dn = self.normalize_dn(parent_dn)
+
+ if isinstance(value, (list, tuple)):
+ value = value[0]
+
+ return DN((attr, value), parent_dn)
+
+ def make_dn(self, entry_attrs, primary_key='cn', parent_dn=None):
+ """
+ Make distinguished name from entry attributes.
+
+ Keyword arguments:
+ primary_key -- attribute from which to make RDN (default 'cn')
+ parent_dn -- DN of the parent entry (default '')
+ """
+
+ assert primary_key in entry_attrs
+
+ if parent_dn is None:
+ parent_dn = DN()
+
+ parent_dn = self.normalize_dn(parent_dn)
+ return DN((primary_key, entry_attrs[primary_key]), parent_dn)
+
class IPAdmin(LDAPConnection):
diff --git a/ipaserver/plugins/ldap2.py b/ipaserver/plugins/ldap2.py
index 28bc8815..fbcad967 100644
--- a/ipaserver/plugins/ldap2.py
+++ b/ipaserver/plugins/ldap2.py
@@ -204,8 +204,8 @@ class ldap2(LDAPConnection, CrudBackend):
Normalize distinguished name by assuring it ends with
the base_dn.
- Note: You don't have to normalize DN's before passing them to
- ldap2 methods. It's done internally for you.
+ Note: ldap2 methods normalize DNs internally, but relying on this is
+ not recommended.
"""
assert isinstance(dn, DN)
@@ -218,40 +218,6 @@ class ldap2(LDAPConnection, CrudBackend):
return dn
- def make_dn_from_attr(self, attr, value, parent_dn=None):
- """
- Make distinguished name from attribute.
-
- Keyword arguments:
- parent_dn -- DN of the parent entry (default '')
- """
- if parent_dn is None:
- parent_dn = DN()
- assert isinstance(parent_dn, DN)
- parent_dn = self.normalize_dn(parent_dn)
-
- if isinstance(value, (list, tuple)):
- value = value[0]
-
- return DN((attr, value), parent_dn)
-
- def make_dn(self, entry_attrs, primary_key='cn', parent_dn=None):
- """
- Make distinguished name from entry attributes.
-
- Keyword arguments:
- primary_key -- attribute from which to make RDN (default 'cn')
- parent_dn -- DN of the parent entry (default '')
- """
-
- assert primary_key in entry_attrs
-
- if parent_dn is None:
- parent_dn = DN()
-
- parent_dn = self.normalize_dn(parent_dn)
- return DN((primary_key, entry_attrs[primary_key]), parent_dn)
-
def add_entry(self, dn, entry_attrs, normalize=True):
"""Create a new entry."""