From c84c417501456310e39723db41e391903224b909 Mon Sep 17 00:00:00 2001 From: Andrea Cimbalo Date: Sun, 28 Jul 2013 17:40:57 +0200 Subject: [PATCH] fix bug --- lilikuser.php | 62 ++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/lilikuser.php b/lilikuser.php index 9147e12..2cd0106 100644 --- a/lilikuser.php +++ b/lilikuser.php @@ -324,34 +324,40 @@ abstract class pippo{ } class LilikGroup extends pippo{ - function __construct($id, $is_posix=False){ - global $HOST, $PORT, $LOGIN_DN; - parent::__construct($id); - $this->adapters=[new GroupAdapter("cn=%s,o=Group,dc=lilik,dc=it")]; - $this->is_posix=$is_posix; - } - - function get_id($user){ - if ($is_posix) - return $user->$id; - else - return sprintf($user->adapters[1]->dn,$user->id); - } - - function add_user($user){ - return $this->add_in_list('member', $this->get_id($user)); - } - - function del_user($user){ - return $this->del_in_list('member', $this->get_id($user)); - } - - function is_user($user){ - if (in_array($this->get_id($user), $this->get_attr('member'))){ - return True; - } - return False; - } + function __construct($id, $is_posix=False){ + global $HOST, $PORT, $LOGIN_DN; + parent::__construct($id); + $this->adapters=[new GroupAdapter("cn=%s,o=Group,dc=lilik,dc=it")]; + $this->is_posix=$is_posix; + if ($is_posix){ + $this->member_attr="memberUid"; + }else{ + $this->member_attr="member"; + } + } + + function get_id($user){ + if ($this->is_posix){ + return $user->id; + }else{ + return sprintf($user->adapters[1]->dn,$user->id); + } + } + + function add_user($user){ + return $this->add_in_list($this->member_attr, $this->get_id($user)); + } + + function del_user($user){ + return $this->del_in_list($this->member_attr, $this->get_id($user)); + } + + function is_user($user){ + if (in_array($this->get_id($user), $this->get_attr($this->member_attr))){ + return True; + } + return False; + } } class LilikUser extends pippo{