$ldap_servers = explode(',', $group['ldap']); echo "Group : {$group['name']}({$group['description']})\n"; if (is_array($config['installedpackages']['dansguardianldap']['config'])) { foreach ($config['installedpackages']['dansguardianldap']['config'] as $server) { if (in_array($server['dc'], $ldap_servers)) { $ldap_dn = $server['dn']; $ldap_host = $server['dc']; $mask = empty($server['mask']) ? "USER" : $server['mask']; if (preg_match("/cn/", $server['username'])) { $ldap_username = $server['username'] . "," . $server['dn']; } else { $ldap_username = $server['username']; } #$domainuser=split("cn=",$server['username']); #$ldap_username=preg_replace("/,\./","@",$domainuser[1].preg_replace("/(,|)DC=/i",".",$server['dn'])); $result = get_ldap_members($group[$ldap_group_source], $ldap_username, $server['password']); if ($group['useraccountcontrol'] != "") { $valid_account_codes = explode(",", $group['useraccountcontrol']); } foreach ($result as $mvalue) { if (preg_match("/\\w+/", $mvalue[0])) { #var_dump($value); $name = preg_replace("/&([a-z])[a-z]+;/i", "\$1", htmlentities($mvalue[1])); //preg_replace('/[^(\x20-\x7F)]*/','', $mvalue[1]); $pattern[0] = "/USER/"; $pattern[1] = "/,/"; $pattern[2] = "/NAME/"; $replace[0] = $mvalue[0]; $replace[1] = "\n"; $replace[2] = "{$name}"; if (is_array($valid_account_codes)) {
$apply_config = 0; if (is_array($config['installedpackages']['dansguardiangroups']['config'])) { foreach ($config['installedpackages']['dansguardiangroups']['config'] as $group) { #ignore default group if ($id > 0) { if ($argv[1] == "" || $argv[1] == $group['name']) { $members = ""; $ldap_servers = explode(',', $group['ldap']); echo "Group : " . $group['name'] . "\n"; if (is_array($config['installedpackages']['dansguardianldap']['config'])) { foreach ($config['installedpackages']['dansguardianldap']['config'] as $server) { if (in_array($server['dc'], $ldap_servers)) { $ldap_dn = $server['dn']; $ldap_host = $server['dc']; $mask = empty($server['mask']) ? "USER" : $server['mask']; $result = get_ldap_members($group['name'], $server['username'] . ',' . $server['dn'], $server['password']); foreach ($result as $key => $value) { if (preg_match("/\\w+/", $value[0])) { #var_dump($value); $name = preg_replace('/[^(\\x20-\\x7F)]*/', '', $value[1]); $pattern[0] = "/USER/"; $pattern[1] = "/,/"; $pattern[2] = "/NAME/"; $replace[0] = $value[0]; $replace[1] = "\n"; $replace[2] = "{$name}"; $members .= preg_replace($pattern, $replace, $mask) . "\n"; } } } }