From a950ae0f077efd2477e60e8a8370fee07fe26b30 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Mon, 15 Feb 2010 12:35:39 -0500 Subject: import release 0.02 --- Changes | 3 +++ lib/DJabberd/Plugin/VCard/LDAP.pm | 48 +++++++++++++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/Changes b/Changes index c7abf7a..4830aab 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for DJabberd-VCard-LDAP +0.02 2007-08-23 + More complete vCard. Support substituting domain as well as userid in filter + 0.01 2007-08-23 First version, released on an unsuspecting world. diff --git a/lib/DJabberd/Plugin/VCard/LDAP.pm b/lib/DJabberd/Plugin/VCard/LDAP.pm index 4606ea4..63a2a6a 100644 --- a/lib/DJabberd/Plugin/VCard/LDAP.pm +++ b/lib/DJabberd/Plugin/VCard/LDAP.pm @@ -15,11 +15,11 @@ DJabberd::VCard::LDAP - LDAP VCard Provider for DJabberd =head1 VERSION -Version 0.01 +Version 0.02 =cut -our $VERSION = '0.01'; +our $VERSION = '0.02'; =head1 SYNOPSIS @@ -38,7 +38,9 @@ Provides an LDAP VCard backend for DJabberd LDAPURI , LDAPBaseDN, and LDAPFilter are required Everything else is optional. -LDAPFilter is an LDAP filter with a %u that will be substituted with the incoming userid (w/o the domain) +LDAPFilter is an LDAP filter substutions + - %u will be substituted with the incoming userid (w/o the domain) (ie. myuser) + - %d will be substituted with the incoming userid's domain (ie. mydoman.com) =cut @@ -98,34 +100,62 @@ sub _isdef { sub load_vcard { my ($self, $user) = @_; - my $suser = $user; - $suser =~ s/^(.*)\@.*$/$1/; + $user =~ /^(.+)\@(.+)$/; + my ($userid,$domain) = ($1, $2); my $filter = $self->{'ldap_filter'}; - $filter =~ s/%u/$suser/; + $filter =~ s/%u/$userid/; + $filter =~ s/%d/$domain/; $logger->info("Searching $filter on ".$self->{'ldap_basedn'}); my $srch = $self->{'ldap_conn'}->search( base=>$self->{'ldap_basedn'}, filter=>$filter, - attrs=>['dn','sn','cn','givenName','mail','telephoneNumber','title','description','displayName']); + attrs=>['dn','sn','cn','givenName','mail','telephoneNumber','title','description','displayName', + 'mobile','company','department','wWWHomePage','homePhone','facsimileTelephoneNumber','pager', + 'streetAddress','co','postalCode','postOfficeBox','st','l','jpegPhoto']); if ($srch->code || $srch->count < 1) { $logger->info("Account $user not found."); return; } else { my $entry = $srch->entry(0); + my $photo = $entry->get_value('jpegPhoto'); + if (defined $photo) { + $photo = ''.$photo.''; + } else { + $photo = ''; + } my $vCard = '' .''._isdef($entry->get_value('cn')).'' .'' .''._isdef($entry->get_value('sn')).'' .''._isdef($entry->get_value('givenName')).'' .'' - .''._isdef($entry->get_value('title')).'' .''._isdef($entry->get_value('displayName')).'' - .''._isdef($entry->get_value('telephoneNumber')).'' + .'' + .''._isdef($entry->get_value('company')).'' + .''._isdef($entry->get_value('department')).'' + .'' + .''._isdef($entry->get_value('title')).'' + .''._isdef($entry->get_value('homePhone')).'' + .''._isdef($entry->get_value('telephoneNumber')).'' + .''._isdef($entry->get_value('facsimileTelephoneNumber')).'' + .''._isdef($entry->get_value('pager')).'' + .''._isdef($entry->get_value('mobile')).'' .''._isdef($entry->get_value('mail')).'' + .'' + .'' + .'' + .''._isdef($entry->get_value('streetAddress')).'' + .''._isdef($entry->get_value('l')).'' + .''._isdef($entry->get_value('st')).'' + .''._isdef($entry->get_value('postalCode')).'' + .''._isdef($entry->get_value('co')).'' + .'' .''.$user.'' + .$photo .''._isdef($entry->get_value('description')).'' .''; + $logger->info($vCard); undef($entry); undef($srch); return $vCard; -- cgit