+# Template for ldap.ini
+#
+# Please copy it to /etc/pixelpark/ldap.ini, <WORKDIR>/etc/ldap.ini
+# or $HOME/.config/pixelpark/ldap.ini to define LDAP-specific configuration values
+# for all LDAP based scripts in this working directory.
+#
+# Please note, that all of these values in the ldap.ini.default file are
+# the default values of the scripts, except bind_pw, which HAS to be configured.
+
[LDAP]
host = ldap.pixelpark.com
port = 389
base_dn = o=isp
bind_dn = uid=Solaris_NSS,ou=Unix NSS,ou=Applications,o=pixelpark,o=isp
-bind_pw = .nss.pro
+#bind_pw = .nss.pro
timeout = 5
+# vim: filetype=dosini
--- /dev/null
+# Template for mk-home.ini
+# Please set the correct Admin password in [LDAP]/bind_pw
+# and copy it to /etc/pixelpark/mk-home.ini, <WORKDIR>/etc/mk-home.ini
+# or $HOME/.config/pixelpark/mk-home.ini to set the correct
+# LDAP credentials for mk-home
+
+[LDAP]
+
+bind_dn = cn=admin
+#bind_pw = <LDAP admin password>
+
+# vim: filetype=dosini
import ldap3
+from ldap3.core.exceptions import LDAPPasswordIsMandatoryError
+
# Own modules
from .global_version import __version__ as __global_version__
from .cfg_app import PpCfgAppError, PpConfigApplication
-__version__ = '0.3.1'
+__version__ = '0.3.2'
LOG = logging.getLogger(__name__)
LOG.debug("executing pre_run() ...")
LOG.debug("Binding to the LDAP servers ...")
- self.ldap_connection.bind()
+ try:
+ self.ldap_connection.bind()
+ except LDAPPasswordIsMandatoryError as e:
+ msg = "Please configure [LDAP]/bind_pw in configuration - " + str(e)
+ self.handle_error(msg, e.__class__.__name__)
+ self.exit(1)
# -------------------------------------------------------------------------
def _run(self):
if dn is None:
dn = self.ldap_base_dn
- self.ldap_connection.search(
- dn, query_filter, search_scope=scope, attributes=attributes)
+ try:
+ self.ldap_connection.search(
+ dn, query_filter, search_scope=scope, attributes=attributes)
+ except LDAPPasswordIsMandatoryError as e:
+ msg = "Please configure [LDAP]/bind_pw in configuration - " + str(e)
+ LOG.error(msg)
+ return []
entries = self.ldap_connection.entries
return entries