diff options
| author | Guilhem Moulin <guilhem.moulin@fripost.org> | 2012-04-28 17:51:04 +0200 | 
|---|---|---|
| committer | Guilhem Moulin <guilhem.moulin@fripost.org> | 2012-04-28 17:51:04 +0200 | 
| commit | 21ac651a4d40472515f5f7d0dd0cd7d27682ee50 (patch) | |
| tree | a6facdc7e832399778bdd6169910530856590a6f | |
| parent | 5dd3d8d080b56d742de3c4b4782cfcde72c3f16f (diff) | |
wibble
| -rwxr-xr-x | fripost-adduser | 8 | ||||
| -rwxr-xr-x | fripost-passwd | 3 | ||||
| -rw-r--r-- | lib/Fripost/Schema/Type/User.pm | 4 | 
3 files changed, 10 insertions, 5 deletions
diff --git a/fripost-adduser b/fripost-adduser index 633926e..168b80c 100755 --- a/fripost-adduser +++ b/fripost-adduser @@ -193,6 +193,10 @@ my ($domain, $login);  { +    # Error if the domain is unknown. +    die "Error: Unknown domain `" .$domain. "'.\n" +        unless $ldap->domain->search({ domain => $domain })->count; +      # Ensure that the username doesn't already exist.      die "Error: User `" .$user->{username}. "' already exists.\n"          if $ldap->user->search({ username => $user->{username} })->count; @@ -206,10 +210,6 @@ my ($domain, $login);          say STDERR ".)";          exit 1;      } - -    # Warn if the domain is unknown. -    warn "WARN: Unknown domain `" .$domain. "'.\n" -        unless $ldap->domain->search({ domain => $domain })->count;  } diff --git a/fripost-passwd b/fripost-passwd index e03deb5..8fad371 100755 --- a/fripost-passwd +++ b/fripost-passwd @@ -153,6 +153,9 @@ $password    //= hash( undef, undef, prompt_password() );  # Ensure that the user exists. +my $domain = (split /\@/, $username, 2)[1]; +die "Error: Unknown domain `" .$domain. "'.\n" +    unless $ldap->domain->search({ domain => $domain })->count;  die "Error: Unknown user `" .$username. "'.\n"      unless $ldap->user->search({ username => $username })->count; diff --git a/lib/Fripost/Schema/Type/User.pm b/lib/Fripost/Schema/Type/User.pm index f5b6ce2..c3075a8 100644 --- a/lib/Fripost/Schema/Type/User.pm +++ b/lib/Fripost/Schema/Type/User.pm @@ -20,7 +20,9 @@ sub search {      my $self = shift;      my $user = shift; -    my ($username, $domain) = split /\@/, $user->{username}, 2; +    my ($username, $domain); +    ($username, $domain) = split /\@/, $user->{username}, 2 +        if defined $user->{username};      my $base  = $self->{_options}->{base_dn};      $base  = join ',', ( 'dc='.$domain, $base )  | 
