Ldap
class Ldap (View source)
Class to manage LDAP features
Constants
| SYNCHRO_NONE |
|
| SYNCHRO_DOLIBARR_TO_LDAP |
|
| SYNCHRO_LDAP_TO_DOLIBARR |
|
Properties
| string | $error | ||
| string[] | $errors | ||
| string[] | $server | ||
| string | $connectedServer | ||
| int | $serverPort | ||
| string | $dn | ||
| string | $serverType | ||
| string | $ldapProtocolVersion | ||
| string | $domain | ||
| string | $domainFQDN | ||
| bool | $bind | ||
| string | $searchUser | ||
| string | $searchPassword | ||
| string | $people | ||
| string | $groups | ||
| int|null | $ldapErrorCode | ||
| string|null | $ldapErrorText | ||
| string | $filter | ||
| string | $filtergroup | ||
| string | $filtermember | ||
| string | $attr_login | ||
| string | $attr_sambalogin | ||
| string | $attr_name | ||
| string | $attr_firstname | ||
| string | $attr_mail | ||
| string | $attr_phone | ||
| string | $attr_fax | ||
| string | $attr_mobile | ||
| int | $badpwdtime | ||
| string | $ldapUserDN | ||
| string | $name | ||
| string | $firstname | ||
| string | $login | ||
| string | $phone | ||
| string | $fax | ||
| string | |||
| string | $mobile | ||
| array<int, string> | $uacf | ||
| int | $pwdlastset | ||
| string | $ldapcharset | ||
| bool|resource | $connection | ||
| bool|resource | $result |
Methods
Constructor
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
Simply closes the connection set up earlier. Returns true if OK, false if there was an error.
Anonymously binds to the connection. After this is done, queries and searches can be done - but read-only.
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".
Unbind of LDAP server (close connection).
Verify LDAP server version
Set LDAP protocol version.
Set LDAP size limit.
Set LDAP referrals.
Modify an LDAP entry (to use if dn != olddn) LDAP object connect and bind must have been done
Delete an LDAP entry LDAP object connect and bind must have been done
Build an LDAP message
Dump an LDAP message to ldapinput.in file
Ping a server before ldap_connect for avoid waiting
Add an LDAP attribute in entry LDAP object connect and bind must have been done
Update an LDAP attribute in entry LDAP object connect and bind must have been done
Delete an LDAP attribute in entry LDAP object connect and bind must have been done
Returns an array containing attributes and values for first record
Returns an array containing values for an attribute and for first record matching filterrecord
Returns an array containing a details or list of LDAP record(s).
Converts a little-endian hex-number to one, that 'hexdec' can convert Required by Active Directory
Gets LDAP user SID.
Returns the textual SID Required by Active Directory
Search method with filter this->connection must be defined. The bind or bindauth methods must already have been called.
Load all attributes of an LDAP user
Returns the correct user identifier to use, based on the LDAP server type
UserAccountControl Flags to more human understandable form.
SamAccountType value to text
Converts ActiveDirectory time to Unix timestamp
Convert a string from output/memory charset
Return available value of group GID
Details
__construct()
Constructor
int
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
bool
close()
deprecated
deprecated
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().
bool
bind()
Anonymously binds to the connection. After this is done, queries and searches can be done - but read-only.
bool
bindauth(string $bindDn, string $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".
bool
unbind()
Unbind of LDAP server (close connection).
int
getVersion()
Verify LDAP server version
bool
setVersion()
Set LDAP protocol version.
LDAP_OPT_PROTOCOL_VERSION is a constant equal to 3
bool
setSizeLimit()
Set LDAP size limit.
bool
setReferrals()
Set LDAP referrals.
LDAP_OPT_REFERRALS is a constant equal to ?
int<-3, -1>|int<1, 1>
add(string $dn, $info, User $user)
Add an LDAP entry LDAP object connect and bind must have been done
int<-3, -1>|int<1, 1>
modify(string $dn, $info, User $user)
Modify an LDAP entry LDAP object connect and bind must have been done
int<-3, -1>|int<1, 1>
rename(string $dn, string $newrdn, string $newparent, User $user, bool $deleteoldrdn = true)
Rename an LDAP entry LDAP object connect and bind must have been done
int<-3, -1>|int<1, 1>
update($dn, array<string, string[]> $info, $user, $olddn, $newrdn = '', string $newparent = '')
Modify an LDAP entry (to use if dn != olddn) LDAP object connect and bind must have been done
@param string $dn DN entry key
int<-3, -1>|int<1, 1>
delete(string $dn)
Delete an LDAP entry LDAP object connect and bind must have been done
string
dumpContent(string $dn, array<string, string[]> $info)
Build an LDAP message
int<-1, -1>|int<1, 1>
dump(string $dn, array<string, string[]> $info)
Dump an LDAP message to ldapinput.in file
bool
serverPing(string $host, int $port = 389, int $timeout = 1)
Ping a server before ldap_connect for avoid waiting
int<-3, -1>|int<1, 1>
addAttribute(string $dn, array<string, string|string[]> $info, User $user)
Add an LDAP attribute in entry LDAP object connect and bind must have been done
int<-3, -1>|int<1, 1>
updateAttribute(string $dn, array<string, string|string[]> $info, User $user)
Update an LDAP attribute in entry LDAP object connect and bind must have been done
int<-3, -1>|int<1, 1>
deleteAttribute(string $dn, array<string, string|string[]> $info, User $user)
Delete an LDAP attribute in entry LDAP object connect and bind must have been done
int<-3, 0>|array<"count"|int, int|mixed[]>
getAttribute(string $dn, string $filter)
Returns an array containing attributes and values for first record
array{count:int,0..max:string|mixed[],string:array}
getAttributeValues($filterrecord, string $attribute)
Returns an array containing values for an attribute and for first record matching filterrecord
@param string $filterrecord Record
array<string, array<string, string>>|int<min, -1>
getRecords(string $search, string $userDn, string $useridentifier, string[] $attributeArray, 0|1|"1"|"user"|"group"|"member" $activefilter = 0, string[] $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
littleEndian(string $hex)
Converts a little-endian hex-number to one, that 'hexdec' can convert Required by Active Directory
int|string
getObjectSid(string $ldapUser)
Gets LDAP user SID.
Required by Active Directory
string
binSIDtoText(string $binsid)
Returns the textual SID Required by Active Directory
array<int|string, int|string|mixed[]>|int<-1, -1>
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.
int
fetch($user, string $filter)
Load all attributes of an LDAP user
@param User|string $user Not used.
string
getUserIdentifier()
Returns the correct user identifier to use, based on the LDAP server type
array<int, string>
parseUACF(string $uacf)
UserAccountControl Flags to more human understandable form.
..
string
parseSAT(string $samtype)
SamAccountType value to text
int
convertTime(string $value)
Converts ActiveDirectory time to Unix timestamp
convFromOutputCharset($str, string $pagecodeto = 'UTF-8')
Convert a string from output/memory charset
@param string $str String to convert
int
getNextGroupGid(string $keygroup = 'LDAP_KEY_GROUPS')
Return available value of group GID