Ejemplo n.º 1
0
*/
require_once 'classes/Session.inc';
Session::logcheck("MenuIntelligence", "CorrelationDirectives");
require_once 'ossim_conf.inc';
require_once 'classes/Security.inc';
/* directories */
$conf = $GLOBALS["CONF"];
$base_dir = $conf->get_conf("base_dir");
$css_dir = '../../style';
$js_dir = '../javascript';
$js_dir_group = 'javascript';
/* connection to the OSSIM database */
require_once '../../include/directive.php';
dbConnect();
/* get the group */
$group = get_group_by_name($_GET['name']);
$framed = $_GET['framed'] != "" ? 1 : 0;
if (!isset($group)) {
    $group = new Group(NULL, NULL, NULL, NULL);
}
$_SESSION['group'] = serialize($group);
/* width */
$list_width = '300px';
if (!($dom = domxml_open_file('/etc/ossim/server/directives.xml', DOMXML_LOAD_SUBSTITUTE_ENTITIES))) {
    echo "Error while parsing the document\n";
    exit;
}
$table = array();
$table_dir = $dom->get_elements_by_tagname('directive');
foreach ($table_dir as $dir) {
    $table[$dir->get_attribute('id')] = $dir->get_attribute('name');
Ejemplo n.º 2
0
function login_ldap($username, $password)
{
    // ldap connecting: must be a valid LDAP server!
    try {
        $ds = ldap_connect("ds.uni-sofia.bg");
    } catch (Exception $e) {
        $error = new Error("User: {$username} failed login:"******"uid={$username},ou=People,dc=uni-sofia,dc=bg";
            $userbind = ldap_bind($ds, $user_dn, $password);
            // verify binding
            if ($userbind) {
                global $ldapRdn;
                global $ldapPass;
                // set ldap bind variables
                $ldaprdn = $ldapRdn;
                $ldappass = $ldapPass;
                // binding to ldap server
                $ldapbind = ldap_bind($ds, $ldaprdn, $ldappass);
                // verify binding
                if ($ldapbind) {
                    // data array
                    $array = array("displayname", "mail", "title", "suscientifictitle", "suscientificdegree", "suFaculty", "suDepartment", "suStudentFaculty", "ou", "objectclass");
                    //$array = array("displayname", "mail", "title");
                    $sr = ldap_search($ds, "ou=People,dc=uni-sofia,dc=bg", "(uid={$username})", $array, 0, 0, 0);
                    $pass = md5($password);
                    $email = "";
                    $givenname = "";
                    $title = "";
                    $staff_groups = "";
                    $student_groups = "";
                    $staff_groups_id = array();
                    $student_groups_id = array();
                    $student_groups_array = array();
                    $staff_groups_array = array();
                    $info = ldap_get_entries($ds, $sr);
                    for ($i = 0; $i < count($info); $i++) {
                        if (isset($info[$i]['mail'])) {
                            $email = $info[$i]['mail'][0];
                        }
                        if (isset($info[$i]['displayname'])) {
                            $givenname = $info[$i]['displayname'][0];
                        }
                        if (isset($info[$i]['title'])) {
                            $title .= $info[$i]['title'][0];
                        }
                        if (isset($info[$i]['suscientifictitle'])) {
                            $title .= " " . $info[$i]['suscientifictitle'][0];
                        }
                        if (isset($info[$i]['suscientificdegree'])) {
                            $title .= " " . $info[$i]['suscientificdegree'][0];
                        }
                        if (isset($info[$i]['objectclass'])) {
                            if (in_array("suStudentPerson", $info[$i]['objectclass']) && !in_array("suFacultyPerson", $info[$i]['objectclass'])) {
                                if (isset($info[$i]['sustudentfaculty'])) {
                                    foreach ($info[$i]['sustudentfaculty'] as $student_group) {
                                        if (!is_int($student_group)) {
                                            array_push($student_groups_array, $student_group);
                                        }
                                    }
                                } elseif (isset($info[$i]['sufaculty'])) {
                                    foreach ($info[$i]['sufaculty'] as $student_group) {
                                        if (!is_int($student_group)) {
                                            array_push($student_groups_array, $student_group);
                                        }
                                    }
                                }
                            }
                            if (in_array("suStaffPerson", $info[$i]['objectclass']) || in_array("suFacultyPerson", $info[$i]['objectclass'])) {
                                if (isset($info[$i]['sufaculty'])) {
                                    foreach ($info[$i]['sufaculty'] as $staff_group) {
                                        if (!is_int($staff_group) && !in_array($staff_group, $student_groups_array)) {
                                            array_push($staff_groups_array, $staff_group);
                                        }
                                    }
                                }
                                if (isset($info[$i]['sudepartment'])) {
                                    foreach ($info[$i]['sudepartment'] as $staff_group) {
                                        if (!is_int($staff_group)) {
                                            array_push($staff_groups_array, $staff_group);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // get the ids of the staff groups
                    foreach ($staff_groups_array as $staff_group_name) {
                        $staff_group_ids = get_group_by_name($staff_group_name);
                        if (!empty($staff_group_ids)) {
                            foreach ($staff_group_ids as $group_id) {
                                $group = new Group();
                                $group->get_from_db($group_id);
                                if ($group->getLocal() == "0" && $group->getStudent() == "0" && $group->getStaff() == "1") {
                                    array_push($staff_groups_id, $group_id);
                                }
                            }
                        }
                    }
                    // get the ids of the student groups
                    foreach ($student_groups_array as $student_group_name) {
                        $student_group_ids = get_group_by_name($student_group_name);
                        if (!empty($student_group_ids)) {
                            foreach ($student_group_ids as $group_id) {
                                $group = new Group();
                                $group->get_from_db($group_id);
                                if ($group->getLocal() == "0" && $group->getStudent() == "1" && $group->getStaff() == "0") {
                                    array_push($student_groups_id, $group_id);
                                }
                            }
                        }
                    }
                    // set common properties
                    $staff_groups .= serialize($staff_groups_id);
                    $student_groups .= serialize($student_groups_id);
                    $user = new User();
                    $user->setUsername($username);
                    $user->setPassword($pass);
                    $user->setLocal(0);
                    $user_exists = get_user_by_username($username);
                    $time_now = date("Y-m-d H:i:s");
                    if (!empty($user_exists)) {
                        $user->get_from_db($user_exists[0]);
                        $user->setGivenname($givenname);
                        $user->setTitle($title);
                        $user->setStaffGroups($staff_groups);
                        $user->setStudentGroups($student_groups);
                        $user->setId($user_exists[0]);
                        $user->setId($pass);
                        $user->setLastEditedOn($time_now);
                        $user->update_in_db();
                        $info = new Info("User: id " . $user->getId() . " update in db");
                        $info->writeLog();
                    } else {
                        $user->setEmail($email);
                        $user->setCanVote(1);
                        $user->setCanAsk(0);
                        $user->setAdmin(0);
                        $user->setGivenname($givenname);
                        $user->setTitle($title);
                        $user->setStaffGroups($staff_groups);
                        $user->setStudentGroups($student_groups);
                        $user->setLocalGroups(serialize(array()));
                        $user->setIsActive(1);
                        $user->setCreatedOn($time_now);
                        $user->setLastEditedOn($time_now);
                        $user->store_in_db();
                        $info = new Info("User: {$username} added in db");
                        $info->writeLog();
                    }
                    ldap_close($ds);
                }
            }
        } catch (Exception $e) {
            $error = new Error("User: {$username} failed login:"******"LDAP server unavailable");
        $error->writeLog();
    }
}
Ejemplo n.º 3
0
        $node->replace_node($new_node);
        $dom->dump_file($file);
    } else {
        $groups = $dom->get_elements_by_tagname('groups');
        $groups = $groups[0];
        $groups->append_child($new_node);
        $dom->dump_file($file);
    }
    echo "<html><body onload=\"top.frames['main'].document.location.href='../numbering.php'\"></body></html>";
} elseif ($query == "delete_group") {
    $file = '/etc/ossim/server/groups.xml';
    if (!($dom = domxml_open_file($file, DOMXML_LOAD_SUBSTITUTE_ENTITIES))) {
        echo _("Error while parsing the document") . "\n";
        exit;
    }
    $name = $_GET['name'];
    $dgroup = get_group_by_name($name);
    $tab_groups = $dom->get_elements_by_tagname('group');
    foreach ($tab_groups as $group) {
        if ($group->get_attribute('name') == $dgroup->name) {
            $node = $group;
        }
    }
    $parent = $node->parent_node();
    $parent->remove_child($node);
    $dom->dump_file($file);
    echo "<html><body onload=\"top.frames['main'].document.location.href='../index.php'\"></body></html>";
}
if ($query != "") {
    dbClose();
}