Live changes
This commit is contained in:
1 parent
f39f8b88ce
commit
2c64cd1d27
7 files changed
+63
-22
No files matched your search
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
require_once("migration/inside_functions.php");
|
||||
class ActionParser {
|
||||
var $action;
|
||||
|
||||
@@ -765,7 +764,6 @@ private function logError($username, $error)
|
||||
}
|
||||
|
||||
public function _deleteEvent() {
|
||||
die('<html><body>Sletting av eventer er midlertidig avskrudd. Ta kontakt med komans@studentersamfundet.no eller edb@studentersamfundet.no for å få slettet ting.</body></html>');
|
||||
Event :: delete(scriptParam("eventid"));
|
||||
}
|
||||
|
||||
@@ -855,8 +853,9 @@ private function logError($username, $error)
|
||||
$user = new User(NULL, $_REQUEST);
|
||||
if ($user->id != -1) {
|
||||
if ($user->store()) {
|
||||
|
||||
/* Push the user to LDAP (nikolark) */
|
||||
$migrated = ldap_add_user($user->username, $user->firstname, $user->lastname, $user->email, $user->password, find_groups());
|
||||
$migrated = ldap_add_user($user->username, $user->firstname, $user->lastname, $user->email, $user->password, Array('dns-alle'));
|
||||
_log($migrated);
|
||||
set_migrated();
|
||||
|
||||
|
||||
+3
-4
@@ -821,10 +821,9 @@ possibly include it instead? --Thomas Misund, 26. Oct 2009
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
/* open the migrate dialog */
|
||||
// TODO: uncomment this.
|
||||
//$( document ).ready( function() {
|
||||
// $("#infomodal").dialog('open');
|
||||
//});
|
||||
$( document ).ready( function() {
|
||||
$("#infomodal").dialog('open');
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ class User {
|
||||
$this->id = -1;
|
||||
return false;
|
||||
}
|
||||
if(preg_match('/^[a-z]*$/', strtolower(stripcslashes($data['username'])))) {
|
||||
if(! preg_match('/^[a-z]*$/', strtolower(stripcslashes($data['username'])))) {
|
||||
notify("Brukernavnet kan kun inneholde små bokstaver.");
|
||||
$this->id = -1;
|
||||
return false;
|
||||
|
||||
@@ -1578,5 +1578,41 @@ function is_migrated() {
|
||||
}
|
||||
return $result->numRows() > 0;
|
||||
}
|
||||
/* Update the migration status */
|
||||
function set_migrated() {
|
||||
$conn = db_connect();
|
||||
$uid = getCurrentUser();
|
||||
|
||||
$sql = sprintf("UPDATE din_user SET migrated=NOW() WHERE id=%s", $uid);
|
||||
$result = $conn->query($sql);
|
||||
|
||||
if (DB :: isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* Find a users groups */
|
||||
function find_groups() {
|
||||
$conn = db_connect();
|
||||
$uid = getCurrentUser();
|
||||
$sql = "SELECT g.posix_group
|
||||
FROM din_usergrouprelationship ugr, din_user u, din_group g
|
||||
WHERE ugr.user_id = $uid
|
||||
AND ugr.user_id = u.id
|
||||
AND ugr.group_id = g.id";
|
||||
$conn->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$result = $conn->getAll($sql);
|
||||
|
||||
if(DB :: isError($result)) {
|
||||
return false;
|
||||
}
|
||||
$arr = array();
|
||||
foreach($result as $column => $group) {
|
||||
$arr[] = $group['posix_group'];
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -13,6 +13,8 @@ setlocale(LC_TIME, $locale);
|
||||
//Extras
|
||||
require_once "functions.php";
|
||||
require_once "language.php";
|
||||
//Migration (nikolark)
|
||||
require_once "migration/ldap_api_functions.php";
|
||||
|
||||
set_include_path("../includes");
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ function user_exists($username) {
|
||||
return $userExists;
|
||||
}
|
||||
/* Update the migration status */
|
||||
if( !function_exists('set_migrated') ) {
|
||||
function set_migrated() {
|
||||
$conn = db_connect();
|
||||
$uid = getCurrentUser();
|
||||
@@ -45,6 +46,7 @@ function set_migrated() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Note: copied from functions.php */
|
||||
if( !function_exists('is_migrated') ) {
|
||||
function is_migrated() {
|
||||
@@ -61,6 +63,7 @@ if( !function_exists('is_migrated') ) {
|
||||
return $result->numRows() > 0;
|
||||
}
|
||||
}
|
||||
if( !function_exists('find_groups') ) {
|
||||
function find_groups() {
|
||||
$conn = db_connect();
|
||||
$uid = getCurrentUser();
|
||||
@@ -82,17 +85,4 @@ function find_groups() {
|
||||
|
||||
return $arr;
|
||||
}
|
||||
function enc_password($password, $key) {
|
||||
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
|
||||
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
|
||||
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $password, MCRYPT_MODE_ECB, $iv);
|
||||
|
||||
$b64enc = base64_encode($crypttext);
|
||||
return $b64enc;
|
||||
/* other end */
|
||||
//$key = "This is a very secret key";
|
||||
//$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
|
||||
//$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
|
||||
//$b64dec = base64_decode($b64enc);
|
||||
//$cleartext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $b64dec, MCRYPT_MODE_ECB, $iv);
|
||||
}
|
||||
@@ -1,11 +1,25 @@
|
||||
<?php
|
||||
require_once("inside_functions.php");
|
||||
require_once('config.php');
|
||||
/* This file is an example on how you might push users from inside to ldap/radius.
|
||||
* * Basically, fill an array with the required attributes, get the API_KEY and the encryption key
|
||||
* * and send it to the file addNewUser.php under brukerinfo.neuf.no.
|
||||
* */
|
||||
|
||||
function enc_password($password, $key) {
|
||||
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
|
||||
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
|
||||
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $password, MCRYPT_MODE_ECB, $iv);
|
||||
|
||||
$b64enc = base64_encode($crypttext);
|
||||
return $b64enc;
|
||||
/* other end */
|
||||
//$key = "This is a very secret key";
|
||||
//$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
|
||||
//$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
|
||||
//$b64dec = base64_decode($b64enc);
|
||||
//$cleartext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $b64dec, MCRYPT_MODE_ECB, $iv);
|
||||
}
|
||||
|
||||
function ldap_add_user($username, $firstname, $lastname, $email, $password, $groups) {
|
||||
/* REQUIRED FOR THE SERVER-SIDE */
|
||||
$ENC_KEY = ENC_KEY;
|
||||
@@ -46,4 +60,5 @@ function _log($str) {
|
||||
$str . "\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user