Changeset 349
- Timestamp:
- 01/12/07 13:06:01 (2 years ago)
- Files:
-
- library/perl/trunk/Catalyst-Model-LDAPx-Simple (added)
- library/perl/trunk/Catalyst-Model-LDAPx-Simple/Changes (added)
- library/perl/trunk/Catalyst-Model-LDAPx-Simple/MANIFEST (added)
- library/perl/trunk/Catalyst-Model-LDAPx-Simple/Makefile.PL (added)
- library/perl/trunk/Catalyst-Model-LDAPx-Simple/README (added)
- library/perl/trunk/Catalyst-Model-LDAPx-Simple/lib (added)
- library/perl/trunk/Catalyst-Model-LDAPx-Simple/lib/Catalyst (added)
- library/perl/trunk/Catalyst-Model-LDAPx-Simple/lib/Catalyst/Model (added)
- library/perl/trunk/Catalyst-Model-LDAPx-Simple/lib/Catalyst/Model/LDAPx (added)
- library/perl/trunk/Catalyst-Model-LDAPx-Simple/lib/Catalyst/Model/LDAPx/Simple.pm (added)
- library/perl/trunk/Catalyst-Model-LDAPx-Simple/t (added)
- library/perl/trunk/Catalyst-Model-LDAPx-Simple/t/00.load.t (added)
- library/perl/trunk/Catalyst-Model-LDAPx-Simple/t/perlcritic.t (added)
- library/perl/trunk/Catalyst-Model-LDAPx-Simple/t/pod-coverage.t (added)
- library/perl/trunk/Catalyst-Model-LDAPx-Simple/t/pod.t (added)
- library/perl/trunk/Net-LDAPx-Simple/lib/Net/LDAPx/Simple.pm (modified) (2 diffs)
- library/perl/trunk/Net-LDAPx-Simple/lib/Net/LDAPx/Simple/Entries.pm (modified) (1 diff)
- library/perl/trunk/Net-LDAPx-Simple/lib/Net/LDAPx/Simple/Entry.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
library/perl/trunk/Net-LDAPx-Simple/lib/Net/LDAPx/Simple.pm
r348 r349 8 8 our $VERSION = qv('0.0.1'); 9 9 10 11 use base qw( Class::Accessor::Fast ); 10 use base qw( Class::Accessor::Fast Class::ErrorHandler ); 12 11 use Net::LDAP; 13 12 use Net::LDAPx::Simple::Context; … … 40 39 41 40 my $msg = $self->{context}->{ldap}->search( 42 base => $self->{base},41 base => $self->{base}, 43 42 filter => $self->_make_filter($args), 44 43 ); 45 44 46 45 return Net::LDAPx::Simple::Entries->new($self->{context}, $msg); 46 } 47 48 sub auth { 49 my ( $self, $args ) = @_; 50 51 $args->{password} ||= $args->{userpassword}; 52 53 return $self->error('No password') unless defined $args->{password}; 54 55 my $entries = $self->search({ uid => $args->{uid} }); 56 57 if ( $entries->count > 1 ) { 58 return $self->error('There are two or more entries'); 59 } 60 61 my $entry = $entries->first; 62 my $res = $self->bind({ 63 dn => $entry->dn, 64 password => $args->{password}, 65 }); 66 67 $self->bind({ 68 dn => $self->{bind_dn}, 69 password => $self->{bind_pw}, 70 }); 71 72 return $res ? $entry : undef; 73 } 74 75 sub bind { 76 my ( $self, $args ) = @_; 77 78 my $mesg = $self->{context}->{ldap}->bind( 79 $args->{dn}, 80 password => $args->{password}, 81 ); 82 83 if ( $mesg->code ) { 84 return $self->error($mesg->error); 85 } 86 else { 87 return 1; 88 } 89 } 90 91 sub create { 92 my ( $self, $args ) = @_; 93 94 my $dn = delete $args->{dn}; 95 96 my $mesg = $self->{context}->{ldap}->add( $dn, attr => [ %$args ] ); 97 98 if ( $mesg->code ) { 99 return $self->error($mesg->error); 100 } 101 else { 102 use Data::Dumper; 103 warn Dumper($mesg); 104 return 1; 105 } 47 106 } 48 107 library/perl/trunk/Net-LDAPx-Simple/lib/Net/LDAPx/Simple/Entries.pm
r348 r349 35 35 } 36 36 37 sub count { 38 my $self = shift; 39 return scalar @{ $self->{entries} }; 40 } 41 37 42 1; library/perl/trunk/Net-LDAPx-Simple/lib/Net/LDAPx/Simple/Entry.pm
r348 r349 5 5 6 6 our $AUTOLOAD; 7 8 use base qw( Class::ErrorHandler ); 7 9 8 10 sub new { … … 25 27 delete $update{context}; 26 28 27 $self->{context}->{ldap}->modify( $self->dn, replace => \%update );29 my $mesg = $self->{context}->{ldap}->modify( $self->dn, replace => \%update ); 28 30 31 if ( $mesg->code ) { 32 return $self->error($mesg->error); 33 } 34 else { 35 return 1; 36 } 37 } 38 39 sub delete { 40 my $self = shift; 41 my $mesg = $self->{context}->{ldap}->delete( $self->dn ); 42 43 if ( $mesg->code ) { 44 return $self->error($mesg->error); 45 } 46 else { 47 return 1; 48 } 29 49 } 30 50
