my $ldap = new Foswiki::Contrib::LdapContrib; $ldap->search( filter => 'mail=*@gmx*', callback => sub { my ($ldap, $entry) = @_; # process entry } ); my $errorMsg = $ldap->getError(); my $count = $result->count(); my @entries = $result->sorted('sn'); my $entry = $result->entry(0); my $dn = $this->getDN($entry); my $commonName = $this->getValue($entry, 'cn'); my $email = $this->getValue($entry, 'mail');
The cache stores a series of key-value pairs in a DB_File. The following keys are used:
Static Method to write a debug messages.
Static Method to write a warning messages.
lib/LocalSite.cfg
.
Connect to LDAP server. If a $dn parameter and a $passwd is given then a bind is done. Otherwise the communication is anonymous. You don't have to connect() explicitely by calling this method. The methods below will do that automatically when needed.
Unbind the LDAP object from the server. This method can be used to force a reconnect and possibly rebind as a different user.
finalize this ldap object.
Private method to check a Net::LDAP::Message object for an error, sets $ldap->{error} and returns the ldap error code. This method is called internally whenever a message object is returned by the server. Use $ldap->getError() to return the actual error message.
Returns the error message of the last LDAP action or undef it no error occured.
Returns the error code of the last LDAP action
Fetches an account entry from the database and returns a Net::LDAP::Entry object on success and undef otherwise. Note, the login name is match against the attribute defined in $ldap->{loginAttribute}. Account records are search using $ldap->{loginFilter} in one of the the subtrees defined in $ldap->{userBase}.
Returns an Net::LDAP::Search object for the given query on success and undef otherwise. If $args{base} is not defined $ldap->{base} is used. If $args{scope} is not defined 'sub' is used (searching down the subtree under $args{base}. If no $args{sizelimit} is set all matching records are returned. The $attrs is a reference to an array of all those attributes that matching entries should contain. If no $args{attrs} is defined all attributes are returned.
If undef is returned as an error occured use $ldap->getError() to get the cleartext message of this search() operation.
Typical usage:$ldap->search( filter=>'uid=TestUser', callback => sub { my ($ldap, $entry) = @_; return unless defined $entry; # process entry } );
Takes an Net::LDAP::Entry and an $attribute name, and stores its value into a file. Returns the pubUrlPath to it. This can be used to store binary large objects like images (jpegPhotos) into the filesystem accessible to the httpd which can serve it in return to the client browser.
Filenames containing the blobs are named using a hash value that is generated using its DN and the actual attribute name whose value is extracted from the database. If the blob already exists in the cache it is not extracted once again except the $refresh parameter is defined. Typical usage:my $blobUrlPath = $ldap->cacheBlob($entry, $attr);
tie the cache with $mode. $mode 'read' ties the cache successfully given that there is only other 'read' locks on it. $mode 'write' ties the cache successfully given that there is no locks on it.
unties the cache
loads/connects to the LDAP cache
reads a topic-based user mapping from a predefined topic and initializes the internal _topicUserMapping hash
download all relevant records from the LDAP server and store it into a database.
download all user records from the LDAP server and cache it into the given hash reference
returns true if new records have been loaded
returns the number of additional entries that have been cached
download all group records from the LDAP server
returns true if new records have been loaded
store a user LDAP::Entry to our internal cache
If the $wikiName parameter is given explicitly then this will be the name under which this record will be cached.
returns true if new records have been created
store a group LDAP::Entry to our internal cache
returns true if new records have been created
normalizes a string to form a proper WikiName
normalizes a string to form a proper login
rewrites a name based on a set of rewrite rules
transliterate some essential utf8 chars to a common replacement in latin1 encoding. the list above is not exhaustive.
use http://www.ltg.ed.ac.uk/~richard/utf-8.html to add more recodingsReturns a list of known group names.
check if a given user is an ldap group actually
fetch emails from LDAP
get all users matching a given email address
check if a given user is member of an ldap group
returns the wikiName of a loginName or undef if it does not exist
returns the loginNAme of a wikiName or undef if it does not exist
returns a list of all known wikiNames
returns a list of all known loginNames
returns the Distinguished Name of the LDAP record of the given name
returns the Distinguished Name of the LDAP record of the given name
returns the wikiName used by a given Distinguished Name; reverse of getDnOfWikiName()
grant that the current loginName is cached. If not, it will download the LDAP record for this specific user and update the LDAP cache with this single record.
This happens when the user is authenticated externally, e.g. using apache's mod_authz_ldap or some other SSO, and the internal cache is not yet updated. It is completely updated regularly on a specific time interval (default every 24h). See the LdapContrib settings.Remove a group from the cache
removes a wikiName from the cache
Insert a new user in the list of unknown users that should not be lookedup in LDAP
returns 1 if $loginName is an unknown user that should not be relookedup in LDAP
Insert a new group in the list of unknown groups that should not be lookedup in LDAP
returns 1 if $groupName is an unknown groups that should not be relookedup in LDAP
grant that the current groupName is cached. If not, it will download the LDAP record for this specific group and its subgroups and update the LDAP cache with the retreived records.
This happens when the precache mode is off. See the LdapContrib settings.Fetches a group entry from the database and returns a Net::LDAP::Entry object on success and undef otherwise. Note, the group name is match against the attribute defined in $ldap->{groupAttribute}. Account records are search using $ldap->{groupFilter} in the subtree defined by $ldap->{groupBase}.
decode strings coming from ldap
returns a decoded string from an Net::LDAP::Entry object
returns the decoded distinguished name from an Net::LDAP::Entry object
returns a decoded an array of strings from an Net::LDAP::Entry object
returns a decoded an array of strings from an Net::LDAP::Entry object
ObjectMethod
loadSession() Load the session, sanitize the login name and make sure its user information are already cached.