/usr/share/perl5/Lemonldap/NG/Portal/RegisterDBAD.pm is in liblemonldap-ng-portal-perl 1.9.16-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | ##@file
# AD register backend file
##@class
# AD register backend class
package Lemonldap::NG::Portal::RegisterDBAD;
use strict;
use Lemonldap::NG::Portal::Simple;
use base qw/Lemonldap::NG::Portal::RegisterDBLDAP/;
use Unicode::String qw(utf8);
## @method int createUser
# Insert new user
# @result Lemonldap::NG::Portal constant
sub createUser {
my ($self) = @_;
my $name =
ucfirst $self->{registerInfo}->{firstname} . " "
. uc $self->{registerInfo}->{lastname};
my $mesg = $self->ldap->add(
"cn=$name," . $self->{ldapBase},
attrs => [
objectClass => [qw/top person organizationalPerson user/],
sAMAccountName => $self->{registerInfo}->{login},
cn => $name,
sn => uc $self->{registerInfo}->{lastname},
givenName => ucfirst $self->{registerInfo}->{firstname},
unicodePwd =>
utf8( chr(34) . $self->{registerInfo}->{password} . chr(34) )
->utf16le(),
mail => $self->{registerInfo}->{mail},
]
);
if ( $mesg->is_error ) {
$self->lmLog(
"Can not create entry for " . $self->{registerInfo}->{login},
'error' );
$self->lmLog( "LDAP error " . $mesg->error, 'error' );
return PE_LDAPERROR;
}
return PE_OK;
}
## @method bool isLoginUsed
# Search if login is already in use
# @result 0 if login is used, 1 else
sub isLoginUsed {
my ( $self, $login ) = @_;
my $mesg = $self->ldap->search(
base => $self->{ldapBase},
filter => "(sAMAccountName=$login)",
scope => "sub",
attrs => ['1.1'],
);
if ( $mesg->code() != 0 ) {
$self->lmLog( "LDAP Search error for $login: " . $mesg->error, 'warn' );
return 1;
}
if ( $mesg->count() > 0 ) {
$self->lmLog( "Login $login already used in LDAP", 'debug' );
return 1;
}
return 0;
}
1;
|