def mmc_create_group(group, description=None): try: createGroup(group) if description is not None: changeGroupDescription(group, description) except ldap.ALREADY_EXISTS: pass
def check(self): if not os.path.exists(self.squidBinary): raise ConfigException("Can't find squid binary: %s" % self.squidBinary) if not os.path.exists(self.sargBinary): raise ConfigException("Can't find sarg binary: %s" % self.sargBinary) if not os.path.exists(self.squidRules): logger.info("Creating %s" % self.squidRules) os.makedirs(self.squidRules) for list in (self.blacklist, self.whitelist, self.blacklist_ext, self.timeranges, self.machines): if not os.path.exists(list): logger.info("Creating %s" % list) open(list, "w+").close() for group, desc in ((self.groupMaster, self.groupMasterDesc), (self.groupFiltered, self.groupFilteredDesc)): if len(getGroupEntry(group)) == 0: createGroup(group) changeGroupDescription(group, desc) logger.info("Group %s created." % group)
print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # Create GLPI-<group> in MMC # Also create it in GLPI # GLPI will query the LDAP for its content but it requires the initial import # to be done through the interface configbase = BasePluginConfig("base") groupsbasedn = configbase.getdn("ldap", "baseGroupsDN") for group in glpi_profiles: group = group[0] # LDAP stuff try: createGroup("GLPI-" + group) except ldap.ALREADY_EXISTS: pass changeGroupDescription("GLPI-" + group, "Users with GLPI " + group + " profile") # MySQL GLPI stuff # BEFORE dropping groups and rules, clean link tables; # May not exists yet: try: # Get group id mysqlcur.execute("SELECT id from %s WHERE name = \"%s\"" % ("glpi_groups", "GLPI-" + group)) groupid = mysqlcur.fetchone()[0] # Get its rules id
def mmc_create_group(group, description): try: createGroup(group) changeGroupDescription(group, description) except ldap.ALREADY_EXISTS: pass
from mmc.plugins.base import createGroup createGroup('Pulse-Admins')
#!/usr/bin/python import ldap from mmc.plugins.base import createGroup, changeGroupDescription from mss.agent.managers.translation import TranslationManager _ = TranslationManager().translate groups = { "InternetMaster": _("Full access to Internet", "squid"), "InternetFiltered": _("Filtered access to Internet", "squid"), } for group, desc in groups.items(): try: createGroup(group) changeGroupDescription(group, desc) except ldap.ALREADY_EXISTS: pass
print "Error %d: %s" % (e.args[0],e.args[1]) sys.exit(1) # Create GLPI-<group> in MMC # Also create it in GLPI # GLPI will query the LDAP for its content but it requires the initial import # to be done through the interface configbase = BasePluginConfig("base") groupsbasedn = configbase.getdn("ldap", "baseGroupsDN") for group in glpi_profiles: group = group[0] # LDAP stuff try: createGroup("GLPI-"+group) except ldap.ALREADY_EXISTS: pass changeGroupDescription("GLPI-"+group, "Users with GLPI "+group+" profile") # MySQL GLPI stuff # BEFORE dropping groups and rules, clean link tables; # May not exists yet: try: # Get group id mysqlcur.execute("SELECT id from %s WHERE name = \"%s\"" % ("glpi_groups","GLPI-"+group)) groupid = mysqlcur.fetchone()[0] # Get its rules id mysqlcur.execute("SELECT id from %s WHERE name = \"%s\"" % ("glpi_rules","Pulse-"+group)) rulesid = mysqlcur.fetchone()[0]