|
dolibarr 20.0.5
|
Class to manage LDAP features. More...

Public Member Functions | |
| __construct () | |
| Constructor. | |
| connectBind () | |
| Connect and bind Use this->server, this->serverPort, this->ldapProtocolVersion, this->serverType, this->searchUser, this->searchPassword After return, this->connection and $this->bind are defined. | |
| close () | |
| Simply closes the connection set up earlier. | |
| bind () | |
| Anonymously binds to the connection. | |
| bindauth ($bindDn, $pass) | |
| Binds as an authenticated user, which usually allows for write access. | |
| unbind () | |
| Unbind of LDAP server (close connection). | |
| getVersion () | |
| Verify LDAP server version. | |
| setVersion () | |
| Set LDAP protocol version. | |
| setSizeLimit () | |
| Set LDAP size limit. | |
| setReferrals () | |
| Set LDAP referrals. | |
| add ($dn, $info, $user) | |
| Add an LDAP entry LDAP object connect and bind must have been done. | |
| modify ($dn, $info, $user) | |
| Modify an LDAP entry LDAP object connect and bind must have been done. | |
| rename ($dn, $newrdn, $newparent, $user, $deleteoldrdn=true) | |
| Rename an LDAP entry LDAP object connect and bind must have been done. | |
| update ($dn, $info, $user, $olddn, $newrdn='', $newparent='') | |
| Modify an LDAP entry (to use if dn != olddn) LDAP object connect and bind must have been done. | |
| delete ($dn) | |
| Delete an LDAP entry LDAP object connect and bind must have been done. | |
| dumpContent ($dn, $info) | |
| Build an LDAP message. | |
| dump ($dn, $info) | |
| Dump an LDAP message to ldapinput.in file. | |
| serverPing ($host, $port=389, $timeout=1) | |
| Ping a server before ldap_connect for avoid waiting. | |
| addAttribute ($dn, $info, $user) | |
| Add an LDAP attribute in entry LDAP object connect and bind must have been done. | |
| updateAttribute ($dn, $info, $user) | |
| Update an LDAP attribute in entry LDAP object connect and bind must have been done. | |
| deleteAttribute ($dn, $info, $user) | |
| Delete an LDAP attribute in entry LDAP object connect and bind must have been done. | |
| getAttribute ($dn, $filter) | |
| Returns an array containing attributes and values for first record. | |
| getAttributeValues ($filterrecord, $attribute) | |
| Returns an array containing values for an attribute and for first record matching filterrecord. | |
| getRecords ($search, $userDn, $useridentifier, $attributeArray, $activefilter=0, $attributeAsArray=array()) | |
| Returns an array containing a details or list of LDAP record(s). | |
| littleEndian ($hex) | |
| Converts a little-endian hex-number to one, that 'hexdec' can convert Required by Active Directory. | |
| getObjectSid ($ldapUser) | |
| Gets LDAP user SID. | |
| binSIDtoText ($binsid) | |
| Returns the textual SID Required by Active Directory. | |
| search ($checkDn, $filter) | |
| Search method with filter this->connection must be defined. | |
| fetch ($user, $filter) | |
| Load all attributes of an LDAP user. | |
| getUserIdentifier () | |
| Returns the correct user identifier to use, based on the LDAP server type. | |
| parseUACF ($uacf) | |
| UserAccountControl Flags to more human understandable form... | |
| parseSAT ($samtype) | |
| SamAccountType value to text. | |
| convertTime ($value) | |
| Converts ActiveDirectory time to Unix timestamp. | |
| convFromOutputCharset ($str, $pagecodeto='UTF-8') | |
| Convert a string from output/memory charset. | |
| getNextGroupGid ($keygroup='LDAP_KEY_GROUPS') | |
| Return available value of group GID. | |
Private Member Functions | |
| convToOutputCharset ($str, $pagecodefrom='UTF-8') | |
| Convert a string into output/memory charset. | |
Class to manage LDAP features.
Definition at line 37 of file ldap.class.php.
| Ldap::add | ( | $dn, | |
| $info, | |||
| $user ) |
Add an LDAP entry LDAP object connect and bind must have been done.
| string | $dn | DN entry key |
| array | $info | Attributes array |
| User | $user | Object user that create |
Definition at line 608 of file ldap.class.php.
References bind(), convFromOutputCharset(), dol_syslog(), and dump().
Referenced by update().
| Ldap::addAttribute | ( | $dn, | |
| $info, | |||
| $user ) |
Add an LDAP attribute in entry LDAP object connect and bind must have been done.
| string | $dn | DN entry key |
| array | $info | Attributes array |
| User | $user | Object user that create |
Definition at line 957 of file ldap.class.php.
References bind(), convFromOutputCharset(), dol_syslog(), and dump().
| Ldap::bind | ( | ) |
Anonymously binds to the connection.
After this is done, queries and searches can be done - but read-only.
Definition at line 488 of file ldap.class.php.
Referenced by add(), addAttribute(), connectBind(), delete(), deleteAttribute(), getAttribute(), modify(), rename(), update(), and updateAttribute().
| Ldap::bindauth | ( | $bindDn, | |
| $pass ) |
Binds as an authenticated user, which usually allows for write access.
The FULL dn must be passed. For a directory manager, this is "cn=Directory Manager" under iPlanet. For a user, it will be something like "uid=jbloggs,ou=People,dc=foo,dc=com".
| string | $bindDn | DN |
| string | $pass | Password |
Definition at line 510 of file ldap.class.php.
Referenced by connectBind(), fetch(), getObjectSid(), getRecords(), and search().
| Ldap::binSIDtoText | ( | $binsid | ) |
Returns the textual SID Required by Active Directory.
| string | $binsid | Binary SID |
Definition at line 1336 of file ldap.class.php.
References littleEndian().
Referenced by getObjectSid().
| Ldap::close | ( | ) |
Simply closes the connection set up earlier.
Returns true if OK, false if there was an error. This method seems a duplicate/alias of unbind().
Definition at line 477 of file ldap.class.php.
References unbind().
| Ldap::connectBind | ( | ) |
Connect and bind Use this->server, this->serverPort, this->ldapProtocolVersion, this->serverType, this->searchUser, this->searchPassword After return, this->connection and $this->bind are defined.
Definition at line 316 of file ldap.class.php.
References bind(), bindauth(), dol_syslog(), getDolGlobalString(), serverPing(), setReferrals(), setSizeLimit(), setVersion(), and unbind().
| Ldap::convertTime | ( | $value | ) |
Converts ActiveDirectory time to Unix timestamp.
| string | $value | AD time to convert |
Definition at line 1574 of file ldap.class.php.
Referenced by fetch().
| Ldap::convFromOutputCharset | ( | $str, | |
| $pagecodeto = 'UTF-8' ) |
Convert a string from output/memory charset.
| string | $str | String to convert |
| string | $pagecodeto | Page code for result string |
Definition at line 1610 of file ldap.class.php.
Referenced by add(), addAttribute(), delete(), deleteAttribute(), modify(), rename(), search(), and updateAttribute().
|
private |
Convert a string into output/memory charset.
| string | $str | String to convert |
| string | $pagecodefrom | Page code of src string |
Definition at line 1591 of file ldap.class.php.
Referenced by fetch(), and getRecords().
| Ldap::delete | ( | $dn | ) |
Delete an LDAP entry LDAP object connect and bind must have been done.
| string | $dn | DN entry key |
Definition at line 808 of file ldap.class.php.
References bind(), convFromOutputCharset(), and dol_syslog().
| Ldap::deleteAttribute | ( | $dn, | |
| $info, | |||
| $user ) |
Delete an LDAP attribute in entry LDAP object connect and bind must have been done.
| string | $dn | DN entry key |
| array | $info | Attributes array |
| User | $user | Object user that create |
Definition at line 1049 of file ldap.class.php.
References bind(), convFromOutputCharset(), dol_syslog(), and dump().
| Ldap::dump | ( | $dn, | |
| $info ) |
Dump an LDAP message to ldapinput.in file.
| string | $dn | DN entry key |
| array | $info | Attributes array |
Definition at line 877 of file ldap.class.php.
References dol_mkdir(), dolChmod(), and dumpContent().
Referenced by add(), addAttribute(), deleteAttribute(), modify(), and updateAttribute().
| Ldap::dumpContent | ( | $dn, | |
| $info ) |
Build an LDAP message.
| string | $dn | DN entry key |
| array | $info | Attributes array |
Definition at line 841 of file ldap.class.php.
Referenced by dump().
| Ldap::fetch | ( | $user, | |
| $filter ) |
Load all attributes of an LDAP user.
| User | string | $user | Not used. |
| string | $filter | Filter for search. Must start with &. Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com) |
Definition at line 1396 of file ldap.class.php.
References bindauth(), convertTime(), convToOutputCharset(), dol_syslog(), name, and parseUACF().
| Ldap::getAttribute | ( | $dn, | |
| $filter ) |
Returns an array containing attributes and values for first record.
| string | $dn | DN entry key |
| string | $filter | Filter |
Definition at line 1093 of file ldap.class.php.
References bind().
| Ldap::getAttributeValues | ( | $filterrecord, | |
| $attribute ) |
Returns an array containing values for an attribute and for first record matching filterrecord.
| string | $filterrecord | Record |
| string | $attribute | Attributes |
Definition at line 1134 of file ldap.class.php.
| Ldap::getNextGroupGid | ( | $keygroup = 'LDAP_KEY_GROUPS' | ) |
Return available value of group GID.
| string | $keygroup | Key of group |
Definition at line 1629 of file ldap.class.php.
References getDolGlobalString(), and search().
| Ldap::getObjectSid | ( | $ldapUser | ) |
Gets LDAP user SID.
Required by Active Directory
| string | $ldapUser | User login |
Definition at line 1286 of file ldap.class.php.
References bindauth(), and binSIDtoText().
Referenced by getRecords().
| Ldap::getRecords | ( | $search, | |
| $userDn, | |||
| $useridentifier, | |||
| $attributeArray, | |||
| $activefilter = 0, | |||
| $attributeAsArray = array() ) |
Returns an array containing a details or list of LDAP record(s).
ldapsearch -LLLx -hlocalhost -Dcn=admin,dc=parinux,dc=org -w password -b "ou=adherents,ou=people,dc=parinux,dc=org" userPassword
| string | $search | Value of field to search, '*' for all. Not used if $activefilter is set. |
| string | $userDn | DN (Ex: ou=adherents,ou=people,dc=parinux,dc=org) |
| string | $useridentifier | Name of key field (Ex: uid). |
| array | $attributeArray | Array of fields required. Note this array must also contain field $useridentifier (Ex: sn,userPassword) |
| int | $activefilter | '1' or 'user'=use field this->filter as filter instead of parameter $search, 'group'=use field this->filtergroup as filter, 'member'=use field this->filtermember as filter |
| array | $attributeAsArray | Array of fields wanted as an array not a string |
Definition at line 1177 of file ldap.class.php.
References bindauth(), convToOutputCharset(), dol_syslog(), and getObjectSid().
| Ldap::getUserIdentifier | ( | ) |
Returns the correct user identifier to use, based on the LDAP server type.
Definition at line 1480 of file ldap.class.php.
| Ldap::getVersion | ( | ) |
| Ldap::littleEndian | ( | $hex | ) |
Converts a little-endian hex-number to one, that 'hexdec' can convert Required by Active Directory.
| string | $hex | Hex value |
Definition at line 1269 of file ldap.class.php.
References dol_strlen().
Referenced by binSIDtoText().
| Ldap::modify | ( | $dn, | |
| $info, | |||
| $user ) |
Modify an LDAP entry LDAP object connect and bind must have been done.
| string | $dn | DN entry key |
| array | $info | Attributes array |
| User | $user | Object user that modify |
Definition at line 656 of file ldap.class.php.
References bind(), convFromOutputCharset(), dol_syslog(), and dump().
Referenced by update().
| Ldap::parseSAT | ( | $samtype | ) |
SamAccountType value to text.
| string | $samtype | SamType |
Definition at line 1542 of file ldap.class.php.
| Ldap::parseUACF | ( | $uacf | ) |
UserAccountControl Flags to more human understandable form...
| string | $uacf | UACF |
Definition at line 1495 of file ldap.class.php.
Referenced by fetch().
| Ldap::rename | ( | $dn, | |
| $newrdn, | |||
| $newparent, | |||
| $user, | |||
| $deleteoldrdn = true ) |
Rename an LDAP entry LDAP object connect and bind must have been done.
| string | $dn | Old DN entry key (uid=qqq,ou=xxx,dc=aaa,dc=bbb) (before update) |
| string | $newrdn | New RDN entry key (uid=qqq) |
| string | $newparent | New parent (ou=xxx,dc=aaa,dc=bbb) |
| User | $user | Object user that modify |
| bool | $deleteoldrdn | If true the old RDN value(s) is removed, else the old RDN value(s) is retained as non-distinguished values of the entry. |
Definition at line 714 of file ldap.class.php.
References bind(), convFromOutputCharset(), and dol_syslog().
Referenced by update().
| Ldap::search | ( | $checkDn, | |
| $filter ) |
Search method with filter this->connection must be defined.
The bind or bindauth methods must already have been called. Do not use for search of a given properties list because of upper-lower case conflict. Only use for pages. 'Fiche LDAP' shows readable fields by default.
| string | $checkDn | Search DN (Ex: ou=users,cn=my-domain,cn=com) |
| string | $filter | Search filter (ex: (sn=name_person) ) |
Definition at line 1363 of file ldap.class.php.
References bindauth(), convFromOutputCharset(), and dol_syslog().
Referenced by getNextGroupGid().
| Ldap::serverPing | ( | $host, | |
| $port = 389, | |||
| $timeout = 1 ) |
Ping a server before ldap_connect for avoid waiting.
| string | $host | Server host or address |
| int | $port | Server port (default 389) |
| int | $timeout | Timeout in second (default 1s) |
Definition at line 910 of file ldap.class.php.
Referenced by connectBind().
| Ldap::setReferrals | ( | ) |
Set LDAP referrals.
LDAP_OPT_REFERRALS is a constant equal to ?
Definition at line 593 of file ldap.class.php.
Referenced by connectBind().
| Ldap::setSizeLimit | ( | ) |
Set LDAP size limit.
Definition at line 582 of file ldap.class.php.
Referenced by connectBind().
| Ldap::setVersion | ( | ) |
Set LDAP protocol version.
LDAP_OPT_PROTOCOL_VERSION is a constant equal to 3
Definition at line 572 of file ldap.class.php.
Referenced by connectBind().
| Ldap::unbind | ( | ) |
Unbind of LDAP server (close connection).
Definition at line 528 of file ldap.class.php.
References dol_syslog().
Referenced by close(), and connectBind().
| Ldap::update | ( | $dn, | |
| $info, | |||
| $user, | |||
| $olddn, | |||
| $newrdn = '', | |||
| $newparent = '' ) |
Modify an LDAP entry (to use if dn != olddn) LDAP object connect and bind must have been done.
| string | $dn | DN entry key |
| array | $info | Attributes array |
| User | $user | Object user that update |
| string | $olddn | Old DN entry key (before update) |
| string | $newrdn | New RDN entry key (uid=qqq) (for ldap_rename) |
| string | $newparent | New parent (ou=xxx,dc=aaa,dc=bbb) (for ldap_rename) |
Definition at line 758 of file ldap.class.php.
References add(), bind(), dol_syslog(), modify(), and rename().
| Ldap::updateAttribute | ( | $dn, | |
| $info, | |||
| $user ) |
Update an LDAP attribute in entry LDAP object connect and bind must have been done.
| string | $dn | DN entry key |
| array | $info | Attributes array |
| User | $user | Object user that create |
Definition at line 1003 of file ldap.class.php.
References bind(), convFromOutputCharset(), dol_syslog(), and dump().