Re: CakePHP LDAP?
I don't think it is, it's just habitOn 6/13/06, RosSoft <[EMAIL PROTECTED]> wrote: Samuel: Is that necessary in PHP4 ? Can you verify it?Because AppModel extends Model -->extends ObjectAnd Object class implements the php4 constructor for compatibility with__construct --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: CakePHP LDAP?
Samuel: Is that necessary in PHP4 ? Can you verify it? Because AppModel extends Model -->extends Object And Object class implements the php4 constructor for compatibility with __construct --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: CakePHP LDAP?
ok thanks samuel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: CakePHP LDAP?
I think that the only changes I made were to add function LdapUser () { $this->__contruct();}On 6/13/06, Levi < [EMAIL PROTECTED]> wrote:Hi SamuelWhat modifications you made when you implement it in PHP4? I'm very interested with this Model...Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: CakePHP LDAP?
Hi Samuel What modifications you made when you implement it in PHP4? I'm very interested with this Model... Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: CakePHP LDAP?
I'm pretty sure its only the __construct() and __destruct() methods.-- JohnOn May 15, 2006, at 2:08 PM, Samuel DeVore wrote:John i use this (if it is mostly the same as the one you sent me a bit ago), with very few changes on php4On 5/15/06, John David Anderson (_psychic_) < [EMAIL PROTECTED]> wrote:I'm going to post this to the group, in hopes that others might find it useful as well.This is what I'm using to do my LDAP stuff in my app. This modellives on a PHP5 system, so it might take a little bit of twiddling toget it running on a PHP4 install.It works with LDAP users as well as LDAP groups, and although it is in sore need of refactoring, I present it here, mostly just to showyou how it might be implemented in Cake:class LdapUser extends AppModel{ var $useTable = false; var $name = 'LdapUser'; var $host = 'ldap.example.com'; var $port = 389; var $baseDn = 'dc=example,dc=com'; var $user = 'cn=admin,dc=example,dc=com'; var $pass = 'secretgoeshere'; var $validate = array( 'givenName' => VALID_NOT_EMPTY, 'sn'=> VALID_NOT_EMPTY ); var $ds; var $inetOrgPersonAttributes = array( 'givenName', 'sn', 'title', 'street', 'l', 'st', 'postalCode', 'telephoneNumber', 'homePhone', 'mobile', 'mail', 'ou' ); var $ouAttributes = array( 'postalAddress', 'l', 'st', 'postalCode', 'telephoneNumber', 'facsimileTelephoneNumber' ); function __construct() { parent::__construct(); $this->ds = ldap_connect($this->host, $this->port); ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_bind($this->ds, $this->user, $this->pass); } function __destruct() { ldap_close($this->ds); } function auth($uid, $password) { $result = $this->findAll('uid', $uid); if($result[0]) { if (ldap_bind($this->ds, $result[0]['dn'], $password)) { return true; } else { return false; } } } function findAll($attribute = 'uid', $value = '*', $baseDn ='ou=People,dc=example,dc=com') { $r = ldap_search($this->ds, $baseDn, $attribute . '=' . $value); if ($r) { //if the result contains entries with surnames, //sort by surname: ldap_sort($this->ds, $r, "sn"); return ldap_get_entries($this->ds, $r); } } function findAllMulti($search, $baseDn = 'dc=example,dc=com') { $r = ldap_search($this->ds, $baseDn, $search); if ($r) { ldap_sort($this->ds, $r, "ou"); return ldap_get_entries($this->ds, $r); } } function add($data) { $data = ""> $r = ldap_bind($this->ds,'cn=admin,dc=example,dc=com', 'secretgoeshere'); $cn = 'cn=' . $data['cn'] . ',ou=' . $data['ou'] .',ou=People,dc=example,dc=com'; $r = ldap_add($this->ds, $cn, $data); if (ldap_error($this->ds) != 'Success') { $_SESSION['error_message'] = ldap_error($this->ds); return false; } return true; } function addGroup($data) { $data = ""> $r = ldap_bind($this->ds,'cn=admin,dc=example,dc=com', 'secretgoeshere'); $cn = 'ou=' . $data['ou'] . ',ou=People,dc=example,dc=com'; $r = ldap_add($this->ds, $cn, $data); if (ldap_error($this->ds) != 'Success') { $_SESSION['error_message'] = ldap_error ($this->ds); return false; } return true; } function modify($oldCn, $data) { $data = "" unset($data['objectClass']); unset($data['cn']); $r = ldap_bind($this->ds,'cn=admin,dc=example,dc=com', 'secretgoeshere'); $cn = 'cn=' . $oldCn . ',ou=' . $data['ou'] . ',ou=People,dc=example,dc=com'; $r = ldap_m
Re: CakePHP LDAP?
John i use this (if it is mostly the same as the one you sent me a bit ago), with very few changes on php4On 5/15/06, John David Anderson (_psychic_) < [EMAIL PROTECTED]> wrote:I'm going to post this to the group, in hopes that others might find it useful as well.This is what I'm using to do my LDAP stuff in my app. This modellives on a PHP5 system, so it might take a little bit of twiddling toget it running on a PHP4 install.It works with LDAP users as well as LDAP groups, and although it is in sore need of refactoring, I present it here, mostly just to showyou how it might be implemented in Cake:class LdapUser extends AppModel{ var $useTable = false; var $name = 'LdapUser'; var $host = 'ldap.example.com'; var $port = 389; var $baseDn = 'dc=example,dc=com'; var $user = 'cn=admin,dc=example,dc=com'; var $pass = 'secretgoeshere'; var $validate = array( 'givenName' => VALID_NOT_EMPTY, 'sn'=> VALID_NOT_EMPTY ); var $ds; var $inetOrgPersonAttributes = array( 'givenName', 'sn', 'title', 'street', 'l', 'st', 'postalCode', 'telephoneNumber', 'homePhone', 'mobile', 'mail', 'ou' ); var $ouAttributes = array( 'postalAddress', 'l', 'st', 'postalCode', 'telephoneNumber', 'facsimileTelephoneNumber' ); function __construct() { parent::__construct(); $this->ds = ldap_connect($this->host, $this->port); ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_bind($this->ds, $this->user, $this->pass); } function __destruct() { ldap_close($this->ds); } function auth($uid, $password) { $result = $this->findAll('uid', $uid); if($result[0]) { if (ldap_bind($this->ds, $result[0]['dn'], $password)) { return true; } else { return false; } } } function findAll($attribute = 'uid', $value = '*', $baseDn ='ou=People,dc=example,dc=com') { $r = ldap_search($this->ds, $baseDn, $attribute . '=' . $value); if ($r) { //if the result contains entries with surnames, //sort by surname: ldap_sort($this->ds, $r, "sn"); return ldap_get_entries($this->ds, $r); } } function findAllMulti($search, $baseDn = 'dc=example,dc=com') { $r = ldap_search($this->ds, $baseDn, $search); if ($r) { ldap_sort($this->ds, $r, "ou"); return ldap_get_entries($this->ds, $r); } } function add($data) { $data = ""> $r = ldap_bind($this->ds,'cn=admin,dc=example,dc=com', 'secretgoeshere'); $cn = 'cn=' . $data['cn'] . ',ou=' . $data['ou'] .',ou=People,dc=example,dc=com'; $r = ldap_add($this->ds, $cn, $data); if (ldap_error($this->ds) != 'Success') { $_SESSION['error_message'] = ldap_error($this->ds); return false; } return true; } function addGroup($data) { $data = ""> $r = ldap_bind($this->ds,'cn=admin,dc=example,dc=com', 'secretgoeshere'); $cn = 'ou=' . $data['ou'] . ',ou=People,dc=example,dc=com'; $r = ldap_add($this->ds, $cn, $data); if (ldap_error($this->ds) != 'Success') { $_SESSION['error_message'] = ldap_error ($this->ds); return false; } return true; } function modify($oldCn, $data) { $data = "" unset($data['objectClass']); unset($data['cn']); $r = ldap_bind($this->ds,'cn=admin,dc=example,dc=com', 'secretgoeshere'); $cn = 'cn=' . $oldCn . ',ou=' . $data['ou'] . ',ou=People,dc=example,dc=com'; $r = ldap_modify($this->ds, $cn, $data); if (ldap_error($this->ds) != 'Success') {
Re: CakePHP LDAP?
I'm going to post this to the group, in hopes that others might find it useful as well. This is what I'm using to do my LDAP stuff in my app. This model lives on a PHP5 system, so it might take a little bit of twiddling to get it running on a PHP4 install. It works with LDAP users as well as LDAP groups, and although it is in sore need of refactoring, I present it here, mostly just to show you how it might be implemented in Cake: VALID_NOT_EMPTY, 'sn'=> VALID_NOT_EMPTY ); var $ds; var $inetOrgPersonAttributes = array( 'givenName', 'sn', 'title', 'street', 'l', 'st', 'postalCode', 'telephoneNumber', 'homePhone', 'mobile', 'mail', 'ou' ); var $ouAttributes = array( 'postalAddress', 'l', 'st', 'postalCode', 'telephoneNumber', 'facsimileTelephoneNumber' ); function __construct() { parent::__construct(); $this->ds = ldap_connect($this->host, $this->port); ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_bind($this->ds, $this->user, $this->pass); } function __destruct() { ldap_close($this->ds); } function auth($uid, $password) { $result = $this->findAll('uid', $uid); if($result[0]) { if (ldap_bind($this->ds, $result[0]['dn'], $password)) { return true; } else { return false; } } } function findAll($attribute = 'uid', $value = '*', $baseDn = 'ou=People,dc=example,dc=com') { $r = ldap_search($this->ds, $baseDn, $attribute . '=' . $value); if ($r) { //if the result contains entries with surnames, //sort by surname: ldap_sort($this->ds, $r, "sn"); return ldap_get_entries($this->ds, $r); } } function findAllMulti($search, $baseDn = 'dc=example,dc=com') { $r = ldap_search($this->ds, $baseDn, $search); if ($r) { ldap_sort($this->ds, $r, "ou"); return ldap_get_entries($this->ds, $r); } } function add($data) { $data = $this->cleanArray($data); $r = ldap_bind($this->ds, 'cn=admin,dc=example,dc=com', 'secretgoeshere'); $cn = 'cn=' . $data['cn'] . ',ou=' . $data['ou'] . ',ou=People,dc=example,dc=com'; $r = ldap_add($this->ds, $cn, $data); if (ldap_error($this->ds) != 'Success') { $_SESSION['error_message'] = ldap_error ($this->ds); return false; } return true; } function addGroup($data) { $data = $this->cleanArray(@$data); $r = ldap_bind($this->ds, 'cn=admin,dc=example,dc=com', 'secretgoeshere'); $cn = 'ou=' . $data['ou'] . ',ou=People,dc=example,dc=com'; $r = ldap_add($this->ds, $cn, $data); if (ldap_error($this->ds) != 'Success') { $_SESSION['error_message'] = ldap_error ($this->ds); return false; } return true; } function modify($oldCn, $data) { $data = $this->cleanArray(@$data); unset($data['objectClass']); unset($data['cn']); $r = ldap_bind($this->ds, 'cn=admin,dc=example,dc=com', 'secretgoeshere'); $cn = 'cn=' . $oldCn . ',ou=' . $data['ou'] . ',ou=People,dc=example,dc=com'; $r = ldap_modify($this->ds, $cn, $data); if (ldap_error($this->ds) != 'Success') { $_SESSION['error_message'] = ldap_error ($this->ds); return false; } foreach($this->inetOrgPersonAttributes as $attr) { if (!empty($data[$attr]) === false) { $todel[strtolower($at