mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Move realm_to_serverid/ldap_uri to ipaldap
The helper function realm_to_serverid() and realm_to_ldap_uri() are useful outside the server installation framework. They are now in ipapython.ipaldap along other helpers for LDAP handling in FreeIPA. Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
committed by
Rob Crittenden
parent
dc33be73f8
commit
d5d9233b7c
@@ -39,12 +39,14 @@ import ldap
|
||||
import ldap.sasl
|
||||
import ldap.filter
|
||||
from ldap.controls import SimplePagedResultsControl, GetEffectiveRightsControl
|
||||
import ldapurl
|
||||
import six
|
||||
|
||||
# pylint: disable=ipa-forbidden-import
|
||||
from ipalib import errors, x509, _
|
||||
from ipalib.constants import LDAP_GENERALIZED_TIME_FORMAT
|
||||
# pylint: enable=ipa-forbidden-import
|
||||
from ipaplatform.paths import paths
|
||||
from ipapython.ipautil import format_netloc, CIDict
|
||||
from ipapython.dn import DN
|
||||
from ipapython.dnsutil import DNSName
|
||||
@@ -90,6 +92,18 @@ if six.PY2 and hasattr(ldap, 'LDAPBytesWarning'):
|
||||
)
|
||||
|
||||
|
||||
def realm_to_serverid(realm_name):
|
||||
"""Convert Kerberos realm name to 389-DS server id"""
|
||||
return "-".join(realm_name.split("."))
|
||||
|
||||
|
||||
def realm_to_ldapi_uri(realm_name):
|
||||
"""Get ldapi:// URI to 389-DS's Unix socket"""
|
||||
serverid = realm_to_serverid(realm_name)
|
||||
socketname = paths.SLAPD_INSTANCE_SOCKET_TEMPLATE % (serverid,)
|
||||
return 'ldapi://' + ldapurl.ldapUrlEscape(socketname)
|
||||
|
||||
|
||||
def ldap_initialize(uri, cacertfile=None):
|
||||
"""Wrapper around ldap.initialize()
|
||||
|
||||
|
Reference in New Issue
Block a user