mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-24 20:01:36 +02:00
Adding users to LDAP is now working
This commit is contained in:
parent
81e28bcd88
commit
703b1c2553
@ -22,7 +22,26 @@
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function descryptpass($userpass, $random)
|
||||||
|
{
|
||||||
|
$lcrypt = "{crypt}";
|
||||||
|
$password = crypt($userpass);
|
||||||
|
$ldappassword = sprintf("%s%s", $lcrypt, $password);
|
||||||
|
|
||||||
|
return $ldappassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
function md5cryptpass($userpass, $random)
|
||||||
|
{
|
||||||
|
$bsalt = "$1$";
|
||||||
|
$lcrypt = "{crypt}";
|
||||||
|
$modsalt = sprintf("%s%s", $bsalt, $random);
|
||||||
|
$password = crypt($userpass, $modsalt);
|
||||||
|
$ldappassword = sprintf("%s%s", $lcrypt, $password);
|
||||||
|
|
||||||
|
return $ldappassword;
|
||||||
|
}
|
||||||
|
|
||||||
function account_read($method,$start,$sort,$order)
|
function account_read($method,$start,$sort,$order)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -30,50 +49,58 @@
|
|||||||
|
|
||||||
function account_add($account_info)
|
function account_add($account_info)
|
||||||
{
|
{
|
||||||
global $phpgw_info, $ldap;
|
global $phpgw_info, $phpgw, $ldap;
|
||||||
|
|
||||||
if ($phpgw_info["server"]["ldap_encryption_type"] == "DES") {
|
if ($phpgw_info["server"]["ldap_encryption_type"] == "DES") {
|
||||||
$salt = randomstring(2);
|
$salt = $phpgw->common->randomstring(2);
|
||||||
$userpassword = descryptpass($account_info["passwd"], $salt);
|
$account_info["passwd"] = descryptpass($account_info["passwd"], $salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($phpgw_info["server"]["ldap_encryption_type"] == "MD5") {
|
if ($phpgw_info["server"]["ldap_encryption_type"] == "MD5") {
|
||||||
$salt = randomstring(9);
|
$salt = $phpgw->common->randomstring(9);
|
||||||
$userpassword = md5cryptpass($account_info["passwd"], $salt);
|
$account_info["passwd"] = md5cryptpass($account_info["passwd"], $salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create our entry
|
// This method is only temp. We need to figure out the best way to assign uidnumbers and
|
||||||
$entry["uid"] = $uid;
|
// guidnumbers.
|
||||||
$entry["uidNumber"] = $uidnumber;
|
|
||||||
$entry["gidNumber"] = $gidnumber;
|
$phpgw->db->query("select (max(account_id)+1) from accounts");
|
||||||
$entry["userpassword"] = $userpassword;
|
$phpgw->db->next_record();
|
||||||
$entry["loginShell"] = $ushell;
|
|
||||||
$entry["homeDirectory"] = $homedir;
|
$account_info["account_id"] = $phpgw->db->f(0);
|
||||||
$entry["cn"] = sprintf("%s %s", $givenname, $sn);
|
|
||||||
$entry["sn"] = $sn;
|
// Much of this is going to be guess work for now, until we get things planned out.
|
||||||
$entry["givenname"] = $givenname;
|
$entry["uid"] = $account_info["loginid"];
|
||||||
$entry["company"] = $company;
|
$entry["uidNumber"] = $account_info["account_id"];
|
||||||
$entry["title"] = $title;
|
$entry["gidNumber"] = $account_info["account_id"];
|
||||||
$entry["mail"] = $mail;
|
$entry["userpassword"] = $account_info["passwd"];
|
||||||
$entry["telephonenumber"] = $telephonenumber;
|
$entry["loginShell"] = "/bin/bash";
|
||||||
$entry["homephone"] = $homephone;
|
$entry["homeDirectory"] = "/home/" . $account_info["loginid"];
|
||||||
$entry["pagerphone"] = $pagerphone;
|
$entry["cn"] = sprintf("%s %s", $account_info["firstname"], $account_info["lastname"]);
|
||||||
$entry["cellphone"] = $cellphone;
|
$entry["sn"] = $account_info["lastname"];
|
||||||
$entry["streetaddress"] = $streetaddress;
|
$entry["givenname"] = $account_info["firstname"];
|
||||||
$entry["locality"] = $locality;
|
//$entry["company"] = $company;
|
||||||
$entry["st"] = $st;
|
//$entry["title"] = $title;
|
||||||
$entry["postalcode"] = $postalcode;
|
$entry["mail"] = $account_info["loginid"] . "@" . $phpgw_info["server"]["mail_suffix"];
|
||||||
$entry["countryname"] = $countryname;
|
//$entry["telephonenumber"] = $telephonenumber;
|
||||||
$entry["homeurl"] = $homeurl;
|
//$entry["homephone"] = $homephone;
|
||||||
$entry["description"] = $description;
|
//$entry["pagerphone"] = $pagerphone;
|
||||||
|
//$entry["cellphone"] = $cellphone;
|
||||||
|
//$entry["streetaddress"] = $streetaddress;
|
||||||
|
//$entry["locality"] = $locality;
|
||||||
|
//$entry["st"] = $st;
|
||||||
|
//$entry["postalcode"] = $postalcode;
|
||||||
|
//$entry["countryname"] = $countryname;
|
||||||
|
//$entry["homeurl"] = $homeurl;
|
||||||
|
//$entry["description"] = $description;
|
||||||
$entry["objectclass"][0] = "account";
|
$entry["objectclass"][0] = "account";
|
||||||
$entry["objectclass"][1] = "posixAccount";
|
$entry["objectclass"][1] = "posixAccount";
|
||||||
$entry["objectclass"][2] = "shadowAccount";
|
$entry["objectclass"][2] = "shadowAccount";
|
||||||
$entry["objectclass"][3] = "inetOrgperson";
|
$entry["objectclass"][3] = "inetOrgperson";
|
||||||
$entry["objectclass"][4] = "person;
|
$entry["objectclass"][4] = "person";
|
||||||
$entry["objectclass"][5] = "top";
|
$entry["objectclass"][5] = "top";
|
||||||
/* $dn=sprintf("cn=%s %s, %s", $givenname, $sn, $BASEDN);*/
|
/* $dn=sprintf("cn=%s %s, %s", $givenname, $sn, $BASEDN);*/
|
||||||
$dn=sprintf("uid=%s, %s", $uid, $BASEDN);
|
$dn=sprintf("uid=%s, %s", $account_info["loginid"], $phpgw_info["server"]["ldap_context"]);
|
||||||
|
|
||||||
// add the entries
|
// add the entries
|
||||||
if (ldap_add($ldap, $dn, $entry)) {
|
if (ldap_add($ldap, $dn, $entry)) {
|
||||||
@ -83,6 +110,51 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ldap_close($ldap);
|
@ldap_close($ldap);
|
||||||
|
|
||||||
|
$phpgw->db->lock(array("accounts","preferences"));
|
||||||
|
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"maxmatchs","common","15");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"theme","common","default");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"tz_offset","common","0");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"dateformat","common","m/d/Y");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"timeformat","common","12");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"lang","common","en");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"company","addressbook","True");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"lastname","addressbook","True");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"firstname","addressbook","True");
|
||||||
|
|
||||||
|
// Even if they don't have access to the calendar, we will add these.
|
||||||
|
// Its better then the calendar being all messed up, they will be deleted
|
||||||
|
// the next time the update there preferences.
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"weekstarts","calendar","Monday");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"workdaystarts","calendar","9");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"workdayends","calendar","17");
|
||||||
|
|
||||||
|
while ($permission = each($account_info["permissions"])) {
|
||||||
|
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
|
||||||
|
$phpgw->accounts->add_app($permission[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "insert into accounts (account_id,account_lid,account_pwd,account_firstname,"
|
||||||
|
. "account_lastname,account_permissions,account_groups,account_status,"
|
||||||
|
. "account_lastpwd_change) values ('" . $account_info["account_id"] . "','"
|
||||||
|
. $account_info["loginid"] . "','x','". addslashes($account_info["firstname"]) . "','"
|
||||||
|
. addslashes($account_info["lastname"]) . "','" . $phpgw->accounts->add_app("",True)
|
||||||
|
. "','" . $account_info["groups"] . "','A',0)";
|
||||||
|
|
||||||
|
$phpgw->db->query($sql);
|
||||||
|
$phpgw->db->unlock();
|
||||||
|
|
||||||
|
$sep = $phpgw->common->filesystem_separator();
|
||||||
|
|
||||||
|
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;
|
||||||
|
|
||||||
|
if (! @mkdir($basedir . $n_loginid, 0707)) {
|
||||||
|
$cd = 36;
|
||||||
|
} else {
|
||||||
|
$cd = 28;
|
||||||
|
}
|
||||||
|
|
||||||
return $cd;
|
return $cd;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user