PHP

From ZENWorks Wiki

Jump to: navigation, search

PHP on Windows LDAPS support

Use phpinfo directive to find out if your php_ldap module is compiled to support ldap ssl

If in the php info output, you see SASL Support => Enabled, than LDAP SSL support is enabled.

Image:file.gifFile: phpinfo.php
<?PHP

phpinfo();

?>


Execute
Linux:> php phpinfo.php


Image:file.gifFile: PHPINFO OutPut
ldap

LDAP Support => enabled RCS Version => $Id: ldap.c,v 1.161.2.3.2.11 2007/07/17 09:09:42 jani Exp $ Total Links => 0/unlimited API Version => 3001 Vendor Name => OpenLDAP Vendor Version => 20337 SASL Support => Enabled



Here's a script that will extend all user objects with an auxiliary class. This script doesn't add an attribute to the user object, it simply makes the user object ready to accept attributes that the auxiliary class contains.

Image:file.gifFile: LDAPAuxClassExtenstion.php
<?PHP

// This script extends an object with an auxiliary class // Nothing is added to the object. The object is simply made to be able to accept attributes that are contained within the auxilary class

//-------------Variables ---------- $host="ldap_host"; //192.168.1.1 $port=ldap_port; //389 $bindDN="cn=admin,o=kc"; $password="password"; $baseDN="base container"; // Highest level container that we want to search from. Example: o=kc $filter="objectclass=inetOrgPerson"; //The type of objects that we want to extend

$entry["objectclass"][0] = "inetOrgPerson"; //Base objectclass that we are going to modify $entry["objectclass"][1] = "jaredAuxClass"; // add an auxiliary objectclass //-------------End of Variables---------

$ds = ldap_connect($host,$port); if (!$ds) {die('Cannot Connect to LDAP server');}

$ldapBind = ldap_bind($ds,$bindDN,$password); if (!$ldapBind) {die('Cannot Bind to LDAP server');}

$justthese = array("cn"); $sr=ldap_search($ds, $baseDN, $filter); $results=ldap_get_entries($ds,$sr); for ($l=0;$l<$results["count"];$l++) {

//echo($results["$l"]["dn"]) . "\n"; $result=ldap_modify($ds, $results["$l"]["dn"], $entry);

if(!$result) {echo('Failed to Modify $results["$l"]["dn"]') . "\n";}

}

ldap_close($ds);

?>
Personal tools