|
|
|
@ -37,6 +37,11 @@ sub _escape {
|
|
|
|
|
return $str; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub _uid_to_dn { |
|
|
|
|
my ($self, $uid) = @_; |
|
|
|
|
return sprintf "uid=%s,%s", $uid, $self->{userbase}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub _filter_username { |
|
|
|
|
my ($self, $uid) = @_; |
|
|
|
|
return bless({and => |
|
|
|
@ -55,7 +60,7 @@ sub create {
|
|
|
|
|
return "User already exists" |
|
|
|
|
if ($data); |
|
|
|
|
|
|
|
|
|
my $dn = sprintf "uid=%s,%s", $uid, $self->{userbase}; |
|
|
|
|
my $dn = $self->_uid_to_dn($uid); |
|
|
|
|
my $result = $conn->add($dn, attr => [ |
|
|
|
|
objectClass => ['inetOrgPerson'], |
|
|
|
|
uid => $uid, |
|
|
|
@ -71,7 +76,7 @@ sub delete {
|
|
|
|
|
my ($self, $uid) = @_; |
|
|
|
|
my $conn = $self->_connect(); |
|
|
|
|
$uid = $self->_escape($uid); |
|
|
|
|
my $dn = sprintf "uid=%s,%s", $uid, $self->{userbase}; |
|
|
|
|
my $dn = $self->_uid_to_dn($uid); |
|
|
|
|
my $result = $conn->delete($dn); |
|
|
|
|
$conn->unbind; |
|
|
|
|
return $result->error if ($result->code); |
|
|
|
@ -110,7 +115,7 @@ sub update {
|
|
|
|
|
return "No such user" |
|
|
|
|
unless ($data); |
|
|
|
|
|
|
|
|
|
my $dn = sprintf "uid=%s,%s", $uid, $self->{userbase}; |
|
|
|
|
my $dn = $self->_uid_to_dn($uid); |
|
|
|
|
my %allowed = map { $_ => 1 } @{$self->{defattrs}}; |
|
|
|
|
my @chg = (); |
|
|
|
|
while (my ($key, $value) = each(%$attrs)) { |
|
|
|
|