Untitled Document Forex Trading Club

Title: dkluenter | Paste from Guest at 2010-03-09 08:58:37 | Syntax: Perl | Hits: 113 | Valid for: Never

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
sub _create_default_abook_user_object {
    my $self = shift;
    my $ldap = shift;
    my $abookdn = $self->{'uadn'};

    # Add user node
    eval {
        $ldap->add ( $abookdn,
                     'attr' => [
                         'objectclass' => [ 'top','bmailNamedObject','simpleSecurityObject'],
                         'uid'=> $self->{'lp'},
                         'userPassword' => "{SASL}".$self->{'login'},
                     ]
            );
    };
    if ($@) {
        if (my $e = Exception::Class->caught('ExistsEx')) {
            #warn "user object already exists -- that's fine";
        }
        else {
            ref $@ ? $@->rethrow : die $@; # hopefully just a missing domain object.
        }
    }
    else {
        print STDERR "Abook ".$self->{'login'}." successfully created!\n" if $BMail::DEBUG > 0;
    }
}

sub create_abook_service {
    _create_abook_service(@_);
}

# Called for new users to create abook base objects on the abook-server
sub _create_abook_service {
    my $self = shift;
    my $conf = $self->{'conf'};

    # Find user abook host.
    my $host = $self->abookserver;

    my $masterDN  = $conf->get('abookDN');
    my $masterpw = $conf->get('abookpw');

    # Open Connection to the abook of the user.
    my $ldap = BMail::Backend::LDAP->new($host,[$masterDN,$masterpw]);
    die "No bind to abook LDAP" unless $ldap; # Either redundant or 
    # Open Connection to the abook of the user.
    my $ldap = BMail::Backend::LDAP->new($host,[$masterDN,$masterpw]);
    die "No bind to abook LDAP" unless $ldap; # Either redundant or really fatal

    my $domainDN = $self->{'abookDomainDN'};

    # Try create user node
    eval {
        $self->_create_default_abook_user_object($ldap);
    };
    if (my $e = Exception::Class->caught('NotFoundEx')) {
        # No such object - maybe this is the first user for the domain
        # Add customer domain object
        print STDERR "Creating Abook domain, DN: $domainDN\n" if $BMail::DEBUG > 0;
        $ldap->add ( $domainDN,
                     'attr' =>
                     [
                      'objectclass' => [ 'top','bmailNamedObject'],
                      'o'=>$self->{'domain'}
                     ]
            );

        # Now try again. - without safety net
        $self->_create_default_abook_user_object($ldap);
    }
    elsif ($@) {
        $self->set_no_abook_service;
        ref $@ ? $@->rethrow : die $@;
    }


» no title
« mess