Add LdapAccount class and use it for list accounts
This commit is contained in:
parent
8e78ac199a
commit
75eedd7645
|
@ -62,11 +62,11 @@ include("inc/debut.php");
|
|||
<tbody>
|
||||
|
||||
<?php
|
||||
$comptes = $domain->getAccounts();
|
||||
foreach ($comptes as $compte) {
|
||||
print '<tr><td style="text-align:left;"><a href="compte.php?domain='.$domain->getName().'&view='.$compte. '">' .$compte. '</a></td>';
|
||||
print '<td>' .getquota($compte,'user'). '</td>';
|
||||
print '<td><a href="compte.php?domain='.$domain->getName().'&del=' .$compte. '"><span class="glyphicon glyphicon-trash"></span></a></td></tr>';
|
||||
$accounts = $domain->getAccounts();
|
||||
foreach ($accounts as $account) {
|
||||
print '<tr><td style="text-align:left;"><a href="compte.php?domain='.$domain->getName().'&account='.$account->getUid().'">' .$account->getName().' <'.$account->getUid().'></a></td>';
|
||||
print '<td>' .getquota($account->getUid(),'user'). '</td>';
|
||||
print '<td><a href="compte.php?domain='.$domain->getName().'&del=' .$account->getUid(). '"><span class="glyphicon glyphicon-trash"></span></a></td></tr>';
|
||||
}
|
||||
print "</tbody></table>";
|
||||
} elseif ( (isset($_GET['viewonly'])) && ($_GET['viewonly']==2) ) {
|
||||
|
|
32
htdocs/lib/class.ldapaccount.php
Normal file
32
htdocs/lib/class.ldapaccount.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
class LdapAccount extends LdapDomain {
|
||||
protected $domain,$uid,$name,$active=false;
|
||||
|
||||
public function __construct($domain, $uid) {
|
||||
$this->conn = $domain->conn;
|
||||
$this->domain = $domain->getName();
|
||||
|
||||
$this->uid = $uid;
|
||||
if ($sr = @ldap_search($this->conn, "uid=".$uid.",cn=".$this->domain.",".LDAP_BASE, "(ObjectClass=mailAccount)")) {
|
||||
$objects = ldap_get_entries($this->conn, $sr);
|
||||
$object = $objects[0];
|
||||
$this->name = $object['cn'][0];
|
||||
//$this->quota = getquota($this->domain,'user');
|
||||
} else {
|
||||
throw new Exception("Ce compte n'existe pas !");
|
||||
}
|
||||
}
|
||||
|
||||
public function getUid() {
|
||||
return $this->uid;
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -48,9 +48,12 @@ class LdapDomain extends LdapServer {
|
|||
$rdn = "ou=people," .LDAP_BASE;
|
||||
}
|
||||
$sr = ldap_search($this->conn, $rdn, "(objectClass=mailAccount)");
|
||||
$info = ldap_get_entries($this->conn, $sr);
|
||||
for ($i=0;$i<$info["count"];$i++) {
|
||||
array_push($this->accounts,$info[$i]["uid"][0]);
|
||||
$objects = ldap_get_entries($this->conn, $sr);
|
||||
foreach($objects as $object) {
|
||||
if(!empty($object["uid"][0])) {
|
||||
$account = new LdapAccount($this, $object["uid"][0]);
|
||||
array_push($this->accounts, $account);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->accounts;
|
||||
|
|
Loading…
Reference in a new issue