lists
[ class tree: lists ] [ index: lists ] [ all elements ]

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:

author:  David Smith
author:  Roland Gruber








arrayLower [line 935]

void arrayLower( $array)



Parameters

   $array  
[ Top ]



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  
[ Top ]



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:

  1.    Array
  2.     (
  3.       [0=> Array
  4.           (
  5.              [dc=example,dc=com=> "dcobject.png"
  6.           )
  7.       [1=> Array
  8.             [o=Corporation=> "o.png"
  9.           )
  10.      )
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.




[ Top ]



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.
[ Top ]



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

   $dn  
[ Top ]



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=&quot;left&quot;'], [ $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:

  1.     draw_jpeg_photos0"cn=Bob,ou=People,dc=example,dc=com""jpegPhoto" truefalse"border: 1px; width: 150px" );
  2.     draw_jpeg_photos1"cn=Fred,ou=People,dc=example,dc=com" );




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  
[ Top ]



draw_server_tree [line 73]

void draw_server_tree( )

Prints the HTML of the tree view.



[ Top ]



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:

return:  The container
see:  get_rdn()


Parameters

string   $dn   The DN whose container string to return.
[ Top ]



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:

  1.  dc=example,dc=com
  2.    ou=People
  3.       cn=Dave
  4.       cn=Fred
  5.       cn=Joe
  6.       ou=More People
  7.          cn=Mark
  8.          cn=Bob

Calling

  1. get_container_contents"ou=people,dc=example,dc=com" )
would return the following list:

  1.   cn=Dave
  2.   cn=Fred
  3.   cn=Joe
  4.   ou=More People




Tags:

return:  An array of DN strings listing the immediate children of the specified entry.


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)"
[ Top ]



get_enc_type [line 1116]

void get_enc_type( $user_password)



Parameters

   $user_password  
[ Top ]



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:

  1.   Array
  2.   (
  3.     [creatorsName=> Array
  4.         (
  5.            [0=> "cn=Admin,dc=example,dc=com"
  6.         )
  7.     [createTimeStamp]=> Array
  8.         (
  9.            [0=> "10401040130"
  10.         )
  11.     [hasSubordinates=> Array
  12.         (
  13.            [0=> "FALSE"
  14.         )
  15.   )




Tags:

return:  An associative array whose keys are attribute names and whose values are arrays of values for the aforementioned attribute.


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.
[ Top ]



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.
[ Top ]



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:

  1.  print_rget_object_attr0"cn=Bob,ou=people,dc=example,dc=com""sn" ) );
  2.  // prints:
  3.  //  Array
  4.  //    (
  5.  //       [0] => "Smith"
  6.  //    )
  7.  
  8.  print_rget_object_attr0"cn=Bob,ou=people,dc=example,dc=com""objectClass" ) );
  9.  // prints:
  10.  //  Array
  11.  //    (
  12.  //       [0] => "top"
  13.  //       [1] => "person"
  14.  //    )




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.
[ Top ]



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

  1. get_object_attrs0"cn=Bob,ou=pepole,dc=example,dc=com" )

  1.  Array
  2.   (
  3.    [objectClass=> Array
  4.        (
  5.            [0=> person
  6.            [1=> top
  7.        )
  8.    [cn=> Array
  9.        (
  10.            [0=> Bob
  11.        )
  12.    [sn=> Array
  13.        (
  14.            [0=> Jones
  15.        )
  16.    [dn=> Array
  17.        (
  18.             [0=> cn=Bob,ou=pepole,dc=example,dc=com
  19.        )
  20.   )




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.
[ Top ]



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:

return:  The RDN
see:  get_container()


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
[ Top ]



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.




[ Top ]



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:

see:  is_jpeg_photo()


Parameters

string   $attr_name   The name of the attribute to test.
[ Top ]



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.
[ Top ]



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)
[ Top ]



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.
[ Top ]



is_mail_string [line 1003]

bool is_mail_string( string $str)

Get whether a string looks like an email address (user@example.com).



Tags:

return:  Returns true if the specified string looks like an email address or false otherwise.


Parameters

string   $str   The string to analyze.
[ Top ]



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:

  1.   ifis_muli_line_attr"postalAddress" ) )
  2.       echo "<textarea name=\"postalAddress\"></textarea>";
  3.   else
  4.       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)
[ Top ]



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:

return:  Returns true if the specified string looks like a web URL or false otherwise.


Parameters

string   $str   The string to analyze.
[ Top ]



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:

  1.        ou=people,dc=example,dc=com
  2.        cn=Admin,ou=People,dc=example,dc=com
  3.        cn=Joe,ou=people,dc=example,dc=com
  4.        dc=example,dc=com
  5.        cn=Fred,ou=people,dc=example,dc=org
  6.        cn=Dave,ou=people,dc=example,dc=org
Will be sorted thus using usort( $list, "pla_compare_dns" ):
  1.        dc=com
  2.        dc=example,dc=com
  3.        ou=people,dc=example,dc=com
  4.        cn=Admin,ou=People,dc=example,dc=com
  5.        cn=Joe,ou=people,dc=example,dc=com
  6.        cn=Dave,ou=people,dc=example,dc=org
  7.        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
[ Top ]



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:

return:  An array of RDN parts of this format:
  1.    Array
  2.     (
  3.        [0=> uid=ppratt
  4.        [1=> ou=People
  5.        [2=> dc=example
  6.        [3=> dc=com
  7.     )


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  
[ Top ]



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:

  1.  $samba_users ldap_search0"(&(objectClass=sambaAccount)(objectClass=posixAccount))",
  2.                               "ou=People,dc=example,dc=com"array"uid""homeDirectory" ) );
  3.  print_r$samba_users );
  4.  // prints (for example):
  5.  //  Array
  6.  //    (
  7.  //       [uid=jsmith,ou=People,dc=example,dc=com] => Array
  8.  //           (
  9.  //               [dn] => "uid=jsmith,ou=People,dc=example,dc=com"
  10.  //               [uid] => "jsmith"
  11.  //               [homeDirectory] => "\\server\jsmith"
  12.  //           )
  13.  //       [uid=byoung,ou=People,dc=example,dc=com] => Array
  14.  //           (
  15.  //               [dn] => "uid=byoung,ou=Samba,ou=People,dc=example,dc=com"
  16.  //               [uid] => "byoung"
  17.  //               [homeDirectory] => "\\server\byoung"
  18.  //           )
  19.  //    )

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.
[ Top ]



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:

  1.    cn=Brigham,ou=People,dc=example,dc=com
Becomes:
  1.    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:

return:  The reversed DN
see:  pla_compare_dns()


Parameters

string   $dn   The DN to reverse
[ Top ]



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.
[ Top ]



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.
[ Top ]



sortAttrs [line 1029]

void sortAttrs( $a, $b)



Parameters

   $a  
   $b  
[ Top ]



Documentation generated on Sun, 04 Nov 2007 12:11:12 +0100 by phpDocumentor 1.4.0