forked from extern/egroupware
Added create function - still needs work
This commit is contained in:
parent
11b69ed7af
commit
f7533ca3d0
@ -61,10 +61,9 @@
|
||||
var $memberships = Array();
|
||||
var $members;
|
||||
|
||||
function accounts_()
|
||||
function accounts()
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
$this->db = $phpgw->db;
|
||||
}
|
||||
|
||||
@ -118,10 +117,12 @@
|
||||
|
||||
function add($account_name, $account_type, $first_name, $last_name, $passwd = False)
|
||||
{
|
||||
$this->create($account_name, $account_type, $first_name, $last_name, $passwd);
|
||||
}
|
||||
|
||||
function delete($account_id)
|
||||
{
|
||||
$this->db->query("DELETE FROM phpgw_accounts WHERE account_id=$account_id");
|
||||
}
|
||||
|
||||
function get_list($_type='both')
|
||||
@ -158,9 +159,7 @@
|
||||
"account_lastname" => $allValues[0]["sn"][0],
|
||||
"account_status" => $this->db->f("account_status")
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$accounts[] = Array(
|
||||
"account_id" => $this->db->f("account_id"),
|
||||
"account_lid" => $this->db->f("account_lid"),
|
||||
@ -183,7 +182,7 @@
|
||||
if($this->db->num_rows()) {
|
||||
$this->db->next_record();
|
||||
return intval($this->db->f("account_id"));
|
||||
}else{
|
||||
} else {
|
||||
return False;
|
||||
}
|
||||
}
|
||||
@ -196,7 +195,7 @@
|
||||
if($this->db->num_rows()) {
|
||||
$this->db->next_record();
|
||||
return $this->db->f("account_lid");
|
||||
}else{
|
||||
} else {
|
||||
return False;
|
||||
}
|
||||
}
|
||||
@ -206,13 +205,10 @@
|
||||
global $phpgw, $phpgw_info;
|
||||
|
||||
$this->db->query("SELECT account_type FROM phpgw_accounts WHERE account_id='".$account_id."'",__LINE__,__FILE__);
|
||||
if ($this->db->num_rows())
|
||||
{
|
||||
if ($this->db->num_rows()) {
|
||||
$this->db->next_record();
|
||||
return $this->db->f("account_type");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return False;
|
||||
}
|
||||
}
|
||||
@ -232,6 +228,48 @@
|
||||
}
|
||||
}
|
||||
|
||||
function create($account_type, $account_lid, $account_pwd, $account_firstname, $account_lastname, $account_status, $account_id='')
|
||||
{
|
||||
global $phpgw_info, $phpgw;
|
||||
|
||||
if (!$account_id) { $account_id = mt_rand (100, 600000); }
|
||||
// auto_increment/serial in the db won't necessarily work for ldap, nor would
|
||||
// randomization. Need to check for lastid in ldap, then create newid for sql and ldap
|
||||
|
||||
/* if (!$account_id) {
|
||||
$this->db->query("insert into phpgw_accounts (account_lid, account_type, account_pwd, "
|
||||
. "account_firstname, account_lastname, account_status) values ('" . $account_lid
|
||||
. "','" . $account_type . "','" . md5($account_pwd) . "', '" . $account_firstname
|
||||
. "','" . $account_lastname . "','" . $account_status . "')",__LINE__,__FILE__);
|
||||
} else { */
|
||||
$this->db->query("insert into phpgw_accounts (account_id, account_lid, account_type, account_pwd, "
|
||||
. "account_firstname, account_lastname, account_status) values ('" . $account_id . "','" . $account_lid
|
||||
. "','" . $account_type . "','" . md5($account_pwd) . "', '" . $account_firstname
|
||||
. "','" . $account_lastname . "','" . $account_status . "')",__LINE__,__FILE__);
|
||||
|
||||
$ds = $phpgw->common->ldapConnect();
|
||||
$sri = ldap_search($ds, $phpgw_info["server"]["ldap_context"], "uidnumber=".$account_id);
|
||||
$allValues = ldap_get_entries($ds, $sri);
|
||||
if (!$allValues[0]["uidnumber"][0]) {
|
||||
$entry["uidnumber"] = $account_id;
|
||||
$entry["gidnumber"] = $account_id;
|
||||
$entry["uid"] = $account_lid;
|
||||
$entry["cn"] = sprintf("%s %s", $account_firstname, $account_lastname);
|
||||
$entry["sn"] = $account_lastname;
|
||||
$entry["givenname"] = $account_firstname;
|
||||
$entry["userpassword"] = $phpgw->common->encrypt_password($account_pwd);
|
||||
$entry["objectclass"][0] = 'person';
|
||||
$entry["objectclass"][1] = 'organizationalPerson';
|
||||
$entry["objectclass"][2] = 'account';
|
||||
$entry["objectclass"][3] = 'posixAccount';
|
||||
$entry["objectclass"][4] = 'shadowAccount';
|
||||
|
||||
$dn = 'uid=' .$account_lid . ',' . $phpgw_info["server"]["ldap_context"];
|
||||
ldap_add($ds, $dn, $entry);
|
||||
//print ldap_error($ds);
|
||||
}
|
||||
}
|
||||
|
||||
function auto_add($account_name, $passwd, $default_prefs=False, $default_acls= False)
|
||||
{
|
||||
print "not done until now auto_generate class.accounts_ldap.inc.php<br>";
|
||||
|
Loading…
Reference in New Issue
Block a user