summaryrefslogtreecommitdiffstats
path: root/ipaserver/ipaldap.py
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2011-09-30 10:09:55 +0200
committerMartin Kosek <mkosek@redhat.com>2011-10-05 10:58:25 +0200
commit12bfed37d4d22319e2cfadb5d9b460da7e748432 (patch)
tree58deb5415d489ac25bad5df267a2df523ba142cc /ipaserver/ipaldap.py
parenta16b5b4c00ca9b82cd40a2c2be22c9e77e0ce64a (diff)
downloadfreeipa-12bfed37d4d22319e2cfadb5d9b460da7e748432.tar.gz
freeipa-12bfed37d4d22319e2cfadb5d9b460da7e748432.tar.xz
freeipa-12bfed37d4d22319e2cfadb5d9b460da7e748432.zip
Add a function for formatting network locations of the form host:port for use in URLs.
If the host part is a literal IPv6 address, it must be enclosed in square brackets (RFC 2732). ticket 1869
Diffstat (limited to 'ipaserver/ipaldap.py')
-rw-r--r--ipaserver/ipaldap.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py
index 4de09f1e5..5477417ac 100644
--- a/ipaserver/ipaldap.py
+++ b/ipaserver/ipaldap.py
@@ -34,6 +34,7 @@ from ldap.controls import LDAPControl,DecodeControlTuples,EncodeControlTuples
from ldap.ldapobject import SimpleLDAPObject
from ipaserver import ipautil
from ipalib import errors
+from ipapython.ipautil import format_netloc
# Global variable to define SASL auth
SASL_AUTH = ldap.sasl.sasl({},'GSSAPI')
@@ -215,12 +216,12 @@ class IPAdmin(SimpleLDAPObject):
its own encryption.
"""
if self.cacert is not None:
- SimpleLDAPObject.__init__(self,'ldaps://%s:%d' % (self.host,self.port))
+ SimpleLDAPObject.__init__(self,'ldaps://%s' % format_netloc(self.host, self.port))
else:
if self.ldapi:
SimpleLDAPObject.__init__(self,'ldapi://%%2fvar%%2frun%%2fslapd-%s.socket' % "-".join(self.realm.split(".")))
else:
- SimpleLDAPObject.__init__(self,'ldap://%s:%d' % (self.host,self.port))
+ SimpleLDAPObject.__init__(self,'ldap://%s' % format_netloc(self.host, self.port))
def __init__(self,host='',port=389,cacert=None,bindcert=None,bindkey=None,proxydn=None,debug=None,ldapi=False,realm=None):
"""We just set our instance variables and wrap the methods - the real
@@ -330,7 +331,7 @@ class IPAdmin(SimpleLDAPObject):
raise errors.DatabaseError(desc=desc,info=info)
def toLDAPURL(self):
- return "ldap://%s:%d/" % (self.host,self.port)
+ return "ldap://%s/" % format_netloc(self.host, self.port)
def set_proxydn(self, proxydn):
self.proxydn = proxydn