diff --git a/htdocs/admin.php b/htdocs/admin.php
index 84291e2..d682d04 100644
--- a/htdocs/admin.php
+++ b/htdocs/admin.php
@@ -62,11 +62,11 @@ include("inc/debut.php");
getAccounts();
- foreach ($comptes as $compte) {
- print '' .$compte. ' | ';
- print '' .getquota($compte,'user'). ' | ';
- print ' |
';
+ $accounts = $domain->getAccounts();
+ foreach ($accounts as $account) {
+ print '' .$account->getName().' <'.$account->getUid().'> | ';
+ print '' .getquota($account->getUid(),'user'). ' | ';
+ print ' |
';
}
print "";
} elseif ( (isset($_GET['viewonly'])) && ($_GET['viewonly']==2) ) {
diff --git a/htdocs/lib/class.ldapaccount.php b/htdocs/lib/class.ldapaccount.php
new file mode 100644
index 0000000..48a175e
--- /dev/null
+++ b/htdocs/lib/class.ldapaccount.php
@@ -0,0 +1,32 @@
+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;
+ }
+}
diff --git a/htdocs/lib/class.ldapdomain.php b/htdocs/lib/class.ldapdomain.php
index 191b9ca..edc2727 100644
--- a/htdocs/lib/class.ldapdomain.php
+++ b/htdocs/lib/class.ldapdomain.php
@@ -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;