From 21ac651a4d40472515f5f7d0dd0cd7d27682ee50 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sat, 28 Apr 2012 17:51:04 +0200 Subject: wibble --- fripost-adduser | 8 ++++---- fripost-passwd | 3 +++ 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 ) -- cgit v1.2.3