aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Fripost/Schema/Domain.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Fripost/Schema/Domain.pm')
-rw-r--r--lib/Fripost/Schema/Domain.pm9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Fripost/Schema/Domain.pm b/lib/Fripost/Schema/Domain.pm
index 56e9737..8c3586f 100644
--- a/lib/Fripost/Schema/Domain.pm
+++ b/lib/Fripost/Schema/Domain.pm
@@ -17,7 +17,7 @@ use warnings;
use utf8;
use parent 'Fripost::Schema';
-use Net::LDAP qw/LDAP_SUCCESS LDAP_COMPARE_TRUE/;
+use Net::LDAP qw/LDAP_SUCCESS LDAP_COMPARE_TRUE LDAP_NO_SUCH_OBJECT/;
use Fripost::Schema::Util qw/concat get_perms explode must_attrs
email_valid canonical_dn/;
use Net::IDN::Encode qw/domain_to_ascii domain_to_unicode
@@ -113,6 +113,8 @@ sub get {
fripostOwner
fripostPostmaster/ ];
+ $attrs = [ '1.1' ] if $options{'-assert_exist'};
+
my $domains = $self->ldap->search(
base => canonical_dn({fvd => $d}, @{$self->suffix}),
scope => 'base',
@@ -133,6 +135,7 @@ sub get {
die $options{'-die'}."\n" if defined $options{'-die'};
die "No such such domain: ā€˜$dā€™\n";
}
+ return if $options{'-assert_exist'};
return ( domain => domain_to_unicode($domain->get_value('fvd'))
, isactive => $domain->get_value('fripostIsStatusActive') eq 'TRUE'
@@ -237,11 +240,11 @@ sub add {
scope => 'base',
deref => 'never',
filter => 'objectClass=FripostVirtualDomain',
- attrs => [] );
+ attrs => [ '1.1' ] );
if ($mesg->code == LDAP_SUCCESS) {
die "Domain ā€˜".$domain."ā€™ already exists.\n";
}
- elsif ($mesg->code != 32) {
+ elsif ($mesg->code != LDAP_NO_SUCH_OBJECT) {
die $mesg->error."\n";
}