Procedural File: tree.inc
Source Location: /lib/tree.inc
Page Details:
This function displays the LDAP tree for all the servers that you have
in config.php. We read the session variable 'tree' to know which dns are expanded or collapsed. No query string parameters are expected, however, you can use a '#' offset to scroll to a given dn. The syntax is tree.php#<rawurlencoded dn>, so if I wanted to scroll to dc=example,dc=com for server 3, the URL would be: tree.php#3_dc%3Dexample%2Cdc%3Dcom
Tags:
arrayLower [line 935]
array_stripslashes [line 61]
void array_stripslashes(
&$array, Array $array)
|
|
Strips all slashes from the specified array in place (pass by ref).
Parameters
Array |
$array |
The array to strip slashes from, typically one of $_GET, $_POST, or $_COOKIE. |
|
&$array |
|
build_initial_tree_icons [line 204]
void build_initial_tree_icons(
)
|
|
Builds the initial array that stores the icon-lookup for each server's DN in the tree browser. The returned array is then stored in the current session. The structure of the returned array is simple, and looks like this: Array
(
[0] => Array
(
[dc=example,dc=com] => "dcobject.png"
)
[1] => Array
[o=Corporation] => "o.png"
)
)
This function is not meant as a user-callable function, but rather a convenient, automated method for setting up the initial data structure for the tree viewer's icon cache.
dn_exists [line 223]
bool dn_exists(
string $dn)
|
|
Gets whether an entry exists based on its DN. If the entry exists, returns true. Otherwise returns false.
Parameters
string |
$dn |
The DN of the entry of interest. |
draw_formatted_dn [line 671]
void draw_formatted_dn(
$dn)
|
|
Gets a DN string using the user-configured tree_display_format string to format it.
Parameters
draw_jpeg_photos [line 1146]
void draw_jpeg_photos(
string $dn, [string $attr_name = 'jpegPhoto'], [bool $draw_delete_buttons = false], [bool $draw_bytes_and_size = true], [string $table_html_attrs = 'align="left"'], [ $img_html_attrs = ''])
|
|
Draw the jpegPhoto image(s) for an entry wrapped in HTML. Many options are available to specify how the images are to be displayed. Usage Examples: draw_jpeg_photos( 0, "cn=Bob,ou=People,dc=example,dc=com", "jpegPhoto" true, false, "border: 1px; width: 150px" );
Parameters
string |
$dn |
The DN of the entry that contains the jpeg attribute you want to draw. |
string |
$attr_name |
The name of the attribute containing the jpeg data (usually 'jpegPhoto'). |
bool |
$draw_delete_buttons |
If true, draws a button beneath the image titled 'Delete' allowing the user to delete the jpeg attribute by calling JavaScript function deleteAttribute() provided in the default modification template. |
bool |
$draw_bytes_and_size |
If true, draw text below the image indicating the byte size and dimensions. |
string |
$table_html_attrs |
Specifies optional CSS style attributes for the table tag. |
|
$img_html_attrs |
|
draw_server_tree [line 73]
Prints the HTML of the tree view.
get_container [line 1324]
string get_container(
string $dn)
|
|
Given a DN string, this returns the parent container portion of the string. For example. given 'cn=Manager,dc=example,dc=com', this function returns 'dc=example,dc=com'.
Tags:
Parameters
string |
$dn |
The DN whose container string to return. |
get_container_contents [line 269]
array get_container_contents(
string $dn, [int $size_limit = 0], [string $filter = '(objectClass=*)'])
|
|
Gets a list of child entries for an entry. Given a DN, this function fetches the list of DNs of child entries one level beneath the parent. For example, for the following tree: dc=example,dc=com
ou=People
cn=Dave
cn=Fred
cn=Joe
ou=More People
cn=Mark
cn=Bob
Calling
would return the following list: cn=Dave
cn=Fred
cn=Joe
ou=More People
Tags:
Parameters
string |
$dn |
The DN of the entry whose children to return. |
int |
$size_limit |
(optional) The maximum number of entries to return. If unspecified, no limit is applied to the number of entries in the returned. |
string |
$filter |
(optional) An LDAP filter to apply when fetching children, example: "(objectClass=inetOrgPerson)" |
get_enc_type [line 1116]
void get_enc_type(
$user_password)
|
|
Parameters
get_entry_system_attrs [line 907]
array get_entry_system_attrs(
string $dn, [int $deref = LDAP_DEREF_NEVER])
|
|
Gets the operational attributes for an entry. Given a DN, this function fetches that entry's operational (ie, system or internal) attributes. These attributes include "createTimeStamp", "creatorsName", and any other attribute that the LDAP server sets automatically. The returned associative array is of this form: Array
(
[creatorsName] => Array
(
[0] => "cn=Admin,dc=example,dc=com"
)
[createTimeStamp]=> Array
(
[0] => "10401040130"
)
[hasSubordinates] => Array
(
[0] => "FALSE"
)
)
Tags:
Parameters
string |
$dn |
The DN of the entry whose interal attributes are desired. |
int |
$deref |
For aliases and referrals, this parameter specifies whether to follow references to the referenced DN or to fetch the attributes for the referencing DN. See http://php.net/ldap_search for the 4 valid options. |
get_icon [line 306]
string get_icon(
string $dn)
|
|
Given a DN and server ID, this function reads the DN's objectClasses and determines which icon best represents the entry. The results of this query are cached in a session variable so it is not run every time the tree browser changes, just when exposing new DNs that were not displayed previously. That means we can afford a little bit of inefficiency here in favor of coolness. :) This function returns a string like "country.png". All icon files are assumed to be contained in the /../../graphics/ directory of phpLDAPadmin. Developers are encouraged to add new icons to the images directory and modify this function as needed to suit their types of LDAP entries. If the modifications are general to an LDAP audience, the phpLDAPadmin team will gladly accept them as a patch.
Parameters
string |
$dn |
The DN of the entry whose icon you wish to fetch. |
get_object_attr [line 450]
void get_object_attr(
string $dn, string $attr, bool $lower_case_attr_names)
|
|
Much like get_object_attrs(), but only returns the values for one attribute of an object. Example calls:
// prints:
// Array
// (
// [0] => "Smith"
// )
// prints:
// Array
// (
// [0] => "top"
// [1] => "person"
// )
Tags:
Parameters
string |
$dn |
The distinguished name (DN) of the entry whose attributes/values to fetch. |
string |
$attr |
The attribute whose value(s) to return (ie, "objectClass", "cn", "userPassword") |
bool |
$lower_case_attr_names |
(optional) If true, all keys of the returned associative array will be lower case. Otherwise, they will be cased as the LDAP server returns them. |
get_object_attrs [line 745]
array get_object_attrs(
string $dn, [bool $lower_case_attr_names = false], [int $deref = LDAP_DEREF_NEVER])
|
|
Gets the attributes/values of an entry. Returns an associative array whose keys are attribute value names and whose values are arrays of values for said attribute. Optionally, callers may specify true for the parameter $lower_case_attr_names to force all keys in the associate array (attribute names) to be lower case. Sample return value of
Array
(
[objectClass] => Array
(
[0] => person
[1] => top
)
[cn] => Array
(
[0] => Bob
)
[sn] => Array
(
[0] => Jones
)
[dn] => Array
(
[0] => cn=Bob,ou=pepole,dc=example,dc=com
)
)
Tags:
Parameters
string |
$dn |
The distinguished name (DN) of the entry whose attributes/values to fetch. |
bool |
$lower_case_attr_names |
(optional) If true, all keys of the returned associative array will be lower case. Otherwise, they will be cased as the LDAP server returns them. |
int |
$deref |
For aliases and referrals, this parameter specifies whether to follow references to the referenced DN or to fetch the attributes for the referencing DN. See http://php.net/ldap_search for the 4 valid options. |
get_rdn [line 484]
string get_rdn(
string $dn, [bool $include_attrs = 0])
|
|
Given a DN string, this returns the 'RDN' portion of the string. For example. given 'cn=Manager,dc=example,dc=com', this function returns 'cn=Manager' (it is really the exact opposite of get_container()).
Tags:
Parameters
string |
$dn |
The DN whose RDN to return. |
bool |
$include_attrs |
If true, include attributes in the RDN string. See http://php.net/ldap_explode_dn for details |
initialize_session_tree [line 167]
void initialize_session_tree(
)
|
|
Checks and fixes an initial session's tree cache if needed. This function is not meant as a user-callable function, but rather a convenient, automated method for checking the initial data structure of the session.
is_attr_binary [line 797]
bool is_attr_binary(
string $attr_name)
|
|
Given an attribute name and server ID number, this function returns whether the attrbiute may contain binary data. This is useful for developers who wish to display the contents of an arbitrary attribute but don't want to dump binary data on the page.
Tags:
Parameters
string |
$attr_name |
The name of the attribute to test. |
is_attr_boolean [line 983]
bool is_attr_boolean(
string $attr_name)
|
|
Given an attribute name and server ID number, this function returns whether the attrbiute contains boolean data. This is useful for developers who wish to display the contents of a boolean attribute with a drop-down.
Parameters
string |
$attr_name |
The name of the attribute to test. |
is_dn_attr [line 1090]
bool is_dn_attr(
string $attr_name)
|
|
Returns true if the attribute specified is required to take as input a DN. Some examples include 'distinguishedName', 'member' and 'uniqueMember'.
Parameters
string |
$attr_name |
The name of the attribute of interest (case insensitive) |
is_jpeg_photo [line 951]
bool is_jpeg_photo(
string $attr_name)
|
|
Used to determine if the specified attribute is indeed a jpegPhoto. If the specified attribute is one that houses jpeg data, true is returned. Otherwise this function returns false.
Tags:
Parameters
string |
$attr_name |
The name of the attribute to test. |
is_mail_string [line 1003]
bool is_mail_string(
string $str)
|
|
Get whether a string looks like an email address (user@example.com).
Tags:
Parameters
string |
$str |
The string to analyze. |
is_multi_line_attr [line 1051]
bool is_multi_line_attr(
string $attr_name, [string $val = null])
|
|
Determines if an attribute's value can contain multiple lines. Attributes that fall in this multi-line category may be configured in config.php. Hence, this function accesses the global variable $multi_line_attributes; Usage example: if( is_muli_line_attr( "postalAddress" ) )
echo "<textarea name=\"postalAddress\"></textarea>";
else
echo "<input name=\"postalAddress\" type=\"text\">";
Parameters
string |
$attr_name |
The name of the attribute of interestd (case insensivite) |
string |
$val |
(optional) The current value of the attribute (speeds up the process by searching for carriage returns already in the attribute value) |
is_url_string [line 1019]
bool is_url_string(
string $str)
|
|
Get whether a string looks like a web URL (http://www.example.com/)
Tags:
Parameters
string |
$str |
The string to analyze. |
pla_compare_dns [line 586]
int pla_compare_dns(
string $dn1, string $dn2)
|
|
Compares 2 DNs. If they are equivelant, returns 0, otherwise, returns their sorting order (similar to strcmp()): Returns < 0 if dn1 is less than dn2. Returns > 0 if dn1 is greater than dn2. The comparison is performed starting with the top-most element of the DN. Thus, the following list: ou=people,dc=example,dc=com
cn=Admin,ou=People,dc=example,dc=com
cn=Joe,ou=people,dc=example,dc=com
dc=example,dc=com
cn=Fred,ou=people,dc=example,dc=org
cn=Dave,ou=people,dc=example,dc=org
Will be sorted thus using usort( $list, "pla_compare_dns" ): dc=com
dc=example,dc=com
ou=people,dc=example,dc=com
cn=Admin,ou=People,dc=example,dc=com
cn=Joe,ou=people,dc=example,dc=com
cn=Dave,ou=people,dc=example,dc=org
cn=Fred,ou=people,dc=example,dc=org
Parameters
string |
$dn1 |
The first of two DNs to compare |
string |
$dn2 |
The second of two DNs to compare |
pla_explode_dn [line 516]
array pla_explode_dn(
string $dn, [ $with_attributes = 0], int $with_attriutes)
|
|
Explode a DN into an array of its RDN parts. This function is UTF-8 safe and replaces the buggy PHP ldap_explode_dn() which does not properly handle UTF-8 DNs and also causes segmentation faults with some inputs.
Tags:
Parameters
string |
$dn |
The DN to explode. |
int |
$with_attriutes |
(optional) Whether to include attribute names (see http://php.net/ldap_explode_dn for details) |
|
$with_attributes |
|
pla_ldap_search [line 1250]
void pla_ldap_search(
string $filter, [string $base_dn = null], [array $attrs = array()], [string $scope = 'sub'], [bool $sort_results = true], [int $deref = LDAP_DEREF_ALWAYS])
|
|
A handy ldap searching function very similar to PHP's ldap_search() with the following exceptions: Callers may specify a search scope and the return value is an array containing the search results rather than an LDAP result resource. Example usage: $samba_users = ldap_search( 0, "(&(objectClass=sambaAccount)(objectClass=posixAccount))",
"ou=People,dc=example,dc=com", array( "uid", "homeDirectory" ) );
// prints (for example):
// Array
// (
// [uid=jsmith,ou=People,dc=example,dc=com] => Array
// (
// [dn] => "uid=jsmith,ou=People,dc=example,dc=com"
// [uid] => "jsmith"
// [homeDirectory] => "\\server\jsmith"
// )
// [uid=byoung,ou=People,dc=example,dc=com] => Array
// (
// [dn] => "uid=byoung,ou=Samba,ou=People,dc=example,dc=com"
// [uid] => "byoung"
// [homeDirectory] => "\\server\byoung"
// )
// )
WARNING: This function will use a lot of memory on large searches since the entire result set is stored in a single array. For large searches, you should consider sing the less memory intensive PHP LDAP API directly (ldap_search(), ldap_next_entry(), ldap_next_attribute(), etc).
Parameters
string |
$filter |
The LDAP filter to use when searching (example: "(objectClass=*)") (see RFC 2254) |
string |
$base_dn |
The DN of the base of search. |
array |
$attrs |
An array of attributes to include in the search result (example: array( "objectClass", "uid", "sn" )). |
string |
$scope |
The LDAP search scope. Must be one of "base", "one", or "sub". Standard LDAP search scope. |
bool |
$sort_results |
Specify false to not sort results by DN or true to have the returned array sorted by DN (uses ksort) |
int |
$deref |
When handling aliases or referrals, this specifies whether to follow referrals. Must be one of LDAP_DEREF_ALWAYS, LDAP_DEREF_NEVER, LDAP_DEREF_SEARCHING, or LDAP_DEREF_FINDING. See the PHP LDAP API for details. |
pla_reverse_dn [line 652]
string pla_reverse_dn(
string $dn)
|
|
Reverses a DN such that the top-level RDN is first and the bottom-level RDN is last For example: cn=Brigham,ou=People,dc=example,dc=com
Becomes: dc=com,dc=example,ou=People,cn=Brigham
This makes it possible to sort lists of DNs such that they are grouped by container.
Tags:
Parameters
string |
$dn |
The DN to reverse |
pretty_print_dn [line 541]
string pretty_print_dn(
string $dn)
|
|
Returns an HTML-beautified version of a DN. Internally, this function makes use of pla_explode_dn() to break the the DN into its components. It then glues them back together with "pretty" HTML. The returned HTML is NOT to be used as a real DN, but simply displayed.
Parameters
string |
$dn |
The DN to pretty-print. |
real_attr_name [line 870]
string real_attr_name(
string $attr_name)
|
|
Prunes off anything after the ";" in an attr name. This is useful for attributes that may have ";binary" appended to their names. With real_attr_name(), you can more easily fetch these attributes' schema with their "real" attribute name.
Parameters
string |
$attr_name |
The name of the attribute to examine. |
sortAttrs [line 1029]
|