from ..errors import DpxWriteLdapItemError
from ..xlate import XLATOR, format_list
-__version__ = '1.4.0'
+__version__ = '1.4.1'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
pattern_dntoken = r'^([^=\s]+)\s*=\s*(\S.*)\S*$'
re_dntoken = re.compile(pattern_dntoken)
+ pattern_ldap_url_service = r'^ldap[si]?://'
+ re_ldap_url_service = re.compile(pattern_ldap_url_service, re.IGNORECASE)
+
person_object_classes = FrozenCIStringSet([
'account', 'inetOrgPerson', 'inetUser', 'posixAccount', 'sambaSamAccount'])
+ helptext_ldap_base_dn = _(
+ 'Override the configured base DN of the instance used as the '
+ 'root for the LDAP searches.')
+
# -------------------------------------------------------------------------
@classmethod
def compare_ldap_dns(cls, x, y):
ldap_group.add_argument(
'-b', '--base-dn', metavar='DN', dest='ldap_base_dn',
- help=_(
- 'Override the configured base DN of the instance used as the '
- 'root for the LDAP searches.')
+ help=self.helptext_ldap_base_dn,
)
ldap_group.add_argument(
LOG.debug(_('Already resolved hostname {h!r} to {a!r}.').format(
h=connect_info.host, a=str(server_ip)))
else:
- LOG.debug(_('Resolving hostname {!r} to an IP address ...').format(connect_info.host))
+ hostname = self.re_ldap_url_service.sub('', connect_info.host)
+ LOG.debug(_('Resolving hostname {!r} to an IP address ...').format(hostname))
try:
- addresses = self.get_address(connect_info.host)
+ addresses = self.get_address(hostname)
except gaierror as e:
- msg = _('Could not resolve hostname {!r}:').format(connect_info.host)
+ msg = _('Could not resolve hostname {!r}:').format(hostname)
msg += ' ' + str(e)
raise DpxNoLdapServerAddressError(msg)
if not addresses:
- msg = _('Could not resolve hostname {!r}.').format(connect_info.host)
+ msg = _('Could not resolve hostname {!r}.').format(hostname)
raise DpxNoLdapServerAddressError(msg)
server_ip = addresses[0]
connect_info.ip = server_ip