Created
August 16, 2017 09:24
-
-
Save p3r7/1965c70c4eeb84c30bad513404a2518c to your computer and use it in GitHub Desktop.
centreonSyncLdapGroups.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Script to force the declaration of all LDAP contact groups after they got lost. | |
* This houdl be placed in the /usr/share/centreon/cron/ directory and executed manually. | |
*/ | |
// ------------------------------------------------------------------------- | |
// REQUIRES | |
include_once "DB.php"; | |
require_once realpath(dirname(__FILE__) . "/../config/centreon.config.php"); | |
include_once _CENTREON_PATH_ . "/cron/centAcl-Func.php"; | |
include_once _CENTREON_PATH_ . "/www/class/centreonDB.class.php"; | |
include_once _CENTREON_PATH_ . "/www/class/centreonLDAP.class.php"; | |
include_once _CENTREON_PATH_ . "/www/class/centreonMeta.class.php"; | |
include_once _CENTREON_PATH_ . "/www/class/centreonContactgroup.class.php"; | |
// ------------------------------------------------------------------------- | |
// INIT | |
$centreonDbName = $conf_centreon['db']; | |
$pearDB = new CentreonDB(); | |
$cg = new CentreonContactgroup($pearDB); | |
$ldapFilter = ''; // taking them all | |
// ------------------------------------------------------------------------- | |
// GET ALL LDAP GROUP | |
$ldapCgs = array(); | |
$ldapCgs = $cg->getLdapContactgroups($ldapFilter); | |
// ------------------------------------------------------------------------- | |
// INSERT / UPDATE THEM IF MISSING IN CENTREON DB | |
foreach ($ldapCgs as $cg_name_with_ar_id => $cg_name_formatted){ | |
$res = $cg->insertLdapGroup($cg_name_with_ar_id); | |
} | |
// ------------------------------------------------------------------------- | |
// ASSOCIATE WITH USERS | |
$cg->syncWithLdap(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment