From e77b0f93f3bd416ad6f63e7a29d6cc0d96ab2678 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 20 May 2022 13:54:30 +0200 Subject: [PATCH] Completing get-ldap-server-info --- lib/pp_admintools/__init__.py | 2 +- lib/pp_admintools/get_ldap_server_info.py | 84 ++++++++++++++++++++++- 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/lib/pp_admintools/__init__.py b/lib/pp_admintools/__init__.py index d92af66..f3ef7f3 100644 --- a/lib/pp_admintools/__init__.py +++ b/lib/pp_admintools/__init__.py @@ -1,7 +1,7 @@ #!/bin/env python3 # -*- coding: utf-8 -*- -__version__ = '0.4.2' +__version__ = '0.4.3' MAX_PORT_NUMBER = (2 ** 16) - 1 MAX_TIMEOUT = 3600 diff --git a/lib/pp_admintools/get_ldap_server_info.py b/lib/pp_admintools/get_ldap_server_info.py index 5b3fede..b5375ec 100644 --- a/lib/pp_admintools/get_ldap_server_info.py +++ b/lib/pp_admintools/get_ldap_server_info.py @@ -32,7 +32,7 @@ from .ldap_app import LdapAppError, BaseLdapApplication, LdapConnection from .xlate import XLATOR -__version__ = '0.1.0' +__version__ = '0.2.1' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -90,6 +90,16 @@ class GetLdapServerInfoApp(BaseLdapApplication): info_data.append((_("Schema entry"), self.get_schema_entry(ldap))) info_data.append((_("Vendor name"), self.get_vendor_name(ldap))) info_data.append((_("Vendor version"), self.get_vendor_version(ldap))) + info_data.append((_("Number of object classes"), self.get_number_object_classes(ldap))) + info_data.append((_("Number of attribute types"), self.get_number_attribute_types(ldap))) + info_data.append((_("Number of matching rules"), self.get_number_matching_rules(ldap))) + info_data.append((_("Number of matching rule uses"), self.get_number_mr_uses(ldap))) + info_data.append(( + _("Number of DIT content rules"), self.get_number_dit_content_rules(ldap))) + info_data.append(( + _("Number of DIT structure rules"), self.get_number_dit_structure_rules(ldap))) + info_data.append((_("Number of name forms"), self.get_number_name_forms(ldap))) + info_data.append((_("Number of ldap syntaxes"), self.get_number_ldap_syntaxes(ldap))) max_len = 1 for entry in info_data: @@ -193,6 +203,78 @@ class GetLdapServerInfoApp(BaseLdapApplication): return vversion + # ------------------------------------------------------------------------- + def get_number_object_classes(self, ldap): + + info = ldap.server.schema.object_classes + if self.verbose > 3: + LOG.debug("Object_classes:\n" + pp(info)) + + return [len(info.keys())] + + # ------------------------------------------------------------------------- + def get_number_attribute_types(self, ldap): + + info = ldap.server.schema.attribute_types + if self.verbose > 3: + LOG.debug("Attribute types:\n" + pp(info)) + + return [len(info.keys())] + + # ------------------------------------------------------------------------- + def get_number_matching_rules(self, ldap): + + info = ldap.server.schema.matching_rules + if self.verbose > 3: + LOG.debug("Matching rules:\n" + pp(info)) + + return [len(info.keys())] + + # ------------------------------------------------------------------------- + def get_number_mr_uses(self, ldap): + + info = ldap.server.schema.matching_rule_uses + if self.verbose > 3: + LOG.debug("Matching rule uses:\n" + pp(info)) + + return [len(info.keys())] + + # ------------------------------------------------------------------------- + def get_number_dit_content_rules(self, ldap): + + info = ldap.server.schema.dit_content_rules + if self.verbose > 3: + LOG.debug("DIT content rules:\n" + pp(info)) + + return [len(info.keys())] + + # ------------------------------------------------------------------------- + def get_number_dit_structure_rules(self, ldap): + + info = ldap.server.schema.dit_structure_rules + if self.verbose > 3: + LOG.debug("DIT structure rules:\n" + pp(info)) + + return [len(info.keys())] + + # ------------------------------------------------------------------------- + def get_number_name_forms(self, ldap): + + info = ldap.server.schema.name_forms + if self.verbose > 3: + LOG.debug("Matching name forms:\n" + pp(info)) + + return [len(info.keys())] + + # ------------------------------------------------------------------------- + def get_number_ldap_syntaxes(self, ldap): + + info = ldap.server.schema.ldap_syntaxes + if self.verbose > 3: + LOG.debug("Matching ldap syntaxes:\n" + pp(info)) + + return [len(info.keys())] + # ============================================================================= -- 2.39.5