<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: CakePHP with full CRUD, a living example!</title>
	<atom:link href="http://www.analogrithems.com/rant/2009/06/12/cakephp-with-full-crud-a-living-example/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.analogrithems.com/rant/2009/06/12/cakephp-with-full-crud-a-living-example/</link>
	<description>If I have seen a little further it is by standing on the shoulders of Giants. - Newton</description>
	<lastBuildDate>Sat, 06 Mar 2010 03:11:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: analogrithems</title>
		<link>http://www.analogrithems.com/rant/2009/06/12/cakephp-with-full-crud-a-living-example/comment-page-1/#comment-1018</link>
		<dc:creator>analogrithems</dc:creator>
		<pubDate>Sat, 06 Mar 2010 03:11:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.analogrithems.com/rant/?p=13#comment-1018</guid>
		<description>I&#039;ve been trying to decide if it should be a config option, or if it should be case statement t try to discover what the ldap server type is.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve been trying to decide if it should be a config option, or if it should be case statement t try to discover what the ldap server type is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benedikt Trefzer</title>
		<link>http://www.analogrithems.com/rant/2009/06/12/cakephp-with-full-crud-a-living-example/comment-page-1/#comment-1017</link>
		<dc:creator>Benedikt Trefzer</dc:creator>
		<pubDate>Fri, 05 Mar 2010 14:58:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.analogrithems.com/rant/?p=13#comment-1017</guid>
		<description>Hi 
I managed to use your database model for a cakephp project connecting to openldap. Good work, congrats.
But I made several changes, which I like to share with you:

Function update:
if((!$this-&gt;in_arrayi(&#039;userpassword&#039;, $update))&amp;&amp; (isset($entry[&#039;userpassword&#039;]))){
=&gt; password needs to be set, to unset. Found the problem, when updating entries without password (eg objectclass top).
same for the following lines:
if (isset($entry[&#039;count&#039;])) { unset($entry[&#039;count&#039;]);}
if (isset($entry[&#039;dn&#039;])) { unset($entry[&#039;dn&#039;]); }

For the return value of the function, I added a return true, if $entry is empthy (if you call update but nothing changes....)

To make the whole story to work with openldap, I changed all occurences of &#039;attributetypes&#039; with &#039;olcattributetypes&#039; and all occurences of  &#039;objectclasses&#039; with &#039;objectclass&#039;.
Then I made: $schemaDN = &#039;cn=schema,cn=config&#039;; (added cn=config). 
Probably it would be a good thing to make this hardcoded things a config option in the database definition.

I still have problems with adding new entries, but give me some time to find out :)
Another trouble: Paging does not work (not implemented, needs limit of data) and Sort is also not working. Could you please tell me if sort is working for you ?

If you like my changes as a path, let me know.

Regards Benedikt</description>
		<content:encoded><![CDATA[<p>Hi<br />
I managed to use your database model for a cakephp project connecting to openldap. Good work, congrats.<br />
But I made several changes, which I like to share with you:</p>
<p>Function update:<br />
if((!$this-&gt;in_arrayi(&#8216;userpassword&#8217;, $update))&amp;&amp; (isset($entry['userpassword']))){<br />
=&gt; password needs to be set, to unset. Found the problem, when updating entries without password (eg objectclass top).<br />
same for the following lines:<br />
if (isset($entry['count'])) { unset($entry['count']);}<br />
if (isset($entry['dn'])) { unset($entry['dn']); }</p>
<p>For the return value of the function, I added a return true, if $entry is empthy (if you call update but nothing changes&#8230;.)</p>
<p>To make the whole story to work with openldap, I changed all occurences of &#8216;attributetypes&#8217; with &#8216;olcattributetypes&#8217; and all occurences of  &#8216;objectclasses&#8217; with &#8216;objectclass&#8217;.<br />
Then I made: $schemaDN = &#8216;cn=schema,cn=config&#8217;; (added cn=config).<br />
Probably it would be a good thing to make this hardcoded things a config option in the database definition.</p>
<p>I still have problems with adding new entries, but give me some time to find out <img src='http://www.analogrithems.com/rant/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Another trouble: Paging does not work (not implemented, needs limit of data) and Sort is also not working. Could you please tell me if sort is working for you ?</p>
<p>If you like my changes as a path, let me know.</p>
<p>Regards Benedikt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: analogrithems</title>
		<link>http://www.analogrithems.com/rant/2009/06/12/cakephp-with-full-crud-a-living-example/comment-page-1/#comment-1015</link>
		<dc:creator>analogrithems</dc:creator>
		<pubDate>Thu, 11 Feb 2010 11:17:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.analogrithems.com/rant/?p=13#comment-1015</guid>
		<description>The foriegn key is how you want to index your ldap data.  If you have the cn and want all your lookups in a certain controller/model to be via the cn then use the cn as your primary group.  This works well in ou=people or ou=group context.  If you are referring to any object in the tree, or you don&#039;t specify the foriegn key then it will be dn.  The foreign key is just the index really.  

In your situation I would make my departments groupofuniquenames and follow the traditional ldap DIT (Directory information tree).  Then include each users dn in that group.  This make more sense in the long run also because if you are using something like apache to perhaps restrict access to a site (For example only billing department can access billing records page).  Then you&#039;ll be happy you followed the standard convention because you can tell apache only people in the group &#039;cn=billing, ou=groups,dc=example,dc=org&#039; are allowed access.  Also some people may be in multiple departments.  What do you do then?  In the group context it&#039;s perfectly fine to have someone in multiple groups.  From the IT perspective I&#039;ve found I often place my IT people in each group to verify they work.  This makes it easier for them to support the end users.</description>
		<content:encoded><![CDATA[<p>The foriegn key is how you want to index your ldap data.  If you have the cn and want all your lookups in a certain controller/model to be via the cn then use the cn as your primary group.  This works well in ou=people or ou=group context.  If you are referring to any object in the tree, or you don&#8217;t specify the foriegn key then it will be dn.  The foreign key is just the index really.  </p>
<p>In your situation I would make my departments groupofuniquenames and follow the traditional ldap DIT (Directory information tree).  Then include each users dn in that group.  This make more sense in the long run also because if you are using something like apache to perhaps restrict access to a site (For example only billing department can access billing records page).  Then you&#8217;ll be happy you followed the standard convention because you can tell apache only people in the group &#8216;cn=billing, ou=groups,dc=example,dc=org&#8217; are allowed access.  Also some people may be in multiple departments.  What do you do then?  In the group context it&#8217;s perfectly fine to have someone in multiple groups.  From the IT perspective I&#8217;ve found I often place my IT people in each group to verify they work.  This makes it easier for them to support the end users.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ldibanyez</title>
		<link>http://www.analogrithems.com/rant/2009/06/12/cakephp-with-full-crud-a-living-example/comment-page-1/#comment-1013</link>
		<dc:creator>ldibanyez</dc:creator>
		<pubDate>Wed, 20 Jan 2010 16:36:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.analogrithems.com/rant/?p=13#comment-1013</guid>
		<description>Hi there,

First of all, congratulations for your effort, is really useful.

I&#039;ve just set it up and succesfully read (thats all i need for the app i&#039;m doing) the users, but now i need some relations between ldap-sourced models and between ldap-sourced and sql-sourced models. I&#039;ve seen that you implemented &#039;generateassociationQuery&#039; but i can&#039;t figure out what goes in the &#039;foreignKey&#039; field.

For example, if i got a set of ou (departments), and inside each of them a set of users, how i say to cake that a user belongsTo a department?

Or maybe i&#039;m just screwing it all up, because foreign key is a relational concept not applicable to ldap, and a i&#039;ll be better making a full dn find to know the users that belong to a department.

Thanks in advance.</description>
		<content:encoded><![CDATA[<p>Hi there,</p>
<p>First of all, congratulations for your effort, is really useful.</p>
<p>I&#8217;ve just set it up and succesfully read (thats all i need for the app i&#8217;m doing) the users, but now i need some relations between ldap-sourced models and between ldap-sourced and sql-sourced models. I&#8217;ve seen that you implemented &#8216;generateassociationQuery&#8217; but i can&#8217;t figure out what goes in the &#8216;foreignKey&#8217; field.</p>
<p>For example, if i got a set of ou (departments), and inside each of them a set of users, how i say to cake that a user belongsTo a department?</p>
<p>Or maybe i&#8217;m just screwing it all up, because foreign key is a relational concept not applicable to ldap, and a i&#8217;ll be better making a full dn find to know the users that belong to a department.</p>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bas Tichelaar</title>
		<link>http://www.analogrithems.com/rant/2009/06/12/cakephp-with-full-crud-a-living-example/comment-page-1/#comment-1012</link>
		<dc:creator>Bas Tichelaar</dc:creator>
		<pubDate>Sun, 17 Jan 2010 17:29:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.analogrithems.com/rant/?p=13#comment-1012</guid>
		<description>Hi, any progress made already?</description>
		<content:encoded><![CDATA[<p>Hi, any progress made already?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: orangepeelbeef</title>
		<link>http://www.analogrithems.com/rant/2009/06/12/cakephp-with-full-crud-a-living-example/comment-page-1/#comment-1011</link>
		<dc:creator>orangepeelbeef</dc:creator>
		<pubDate>Sat, 16 Jan 2010 01:23:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.analogrithems.com/rant/?p=13#comment-1011</guid>
		<description>figured it out:

controller:

 $user = $this-&gt;LdapAuth-&gt;user();
 $this-&gt;set(compact(&#039;user&#039;));


then can retrieve as  

view:
echo $user[&#039;User&#039;][&#039;mail&#039;]</description>
		<content:encoded><![CDATA[<p>figured it out:</p>
<p>controller:</p>
<p> $user = $this-&gt;LdapAuth-&gt;user();<br />
 $this-&gt;set(compact(&#8216;user&#8217;));</p>
<p>then can retrieve as  </p>
<p>view:<br />
echo $user['User']['mail']</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: orangepeelbeef</title>
		<link>http://www.analogrithems.com/rant/2009/06/12/cakephp-with-full-crud-a-living-example/comment-page-1/#comment-1010</link>
		<dc:creator>orangepeelbeef</dc:creator>
		<pubDate>Sat, 16 Jan 2010 01:02:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.analogrithems.com/rant/?p=13#comment-1010</guid>
		<description>Thanks, that was a big help.  I now can view the ldap user data within the users controller, but how do I know what the uid of the user who is currently logged in is?  That is the last piece I&#039;m missing to make this functional.  I also want to do some differing access levels based on what ldap group the user is in, so I need to be able to access the ldap info for the user who previously logged in.  I used beforefilters to force a login for all my pages.</description>
		<content:encoded><![CDATA[<p>Thanks, that was a big help.  I now can view the ldap user data within the users controller, but how do I know what the uid of the user who is currently logged in is?  That is the last piece I&#8217;m missing to make this functional.  I also want to do some differing access levels based on what ldap group the user is in, so I need to be able to access the ldap info for the user who previously logged in.  I used beforefilters to force a login for all my pages.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: analogrithems</title>
		<link>http://www.analogrithems.com/rant/2009/06/12/cakephp-with-full-crud-a-living-example/comment-page-1/#comment-1009</link>
		<dc:creator>analogrithems</dc:creator>
		<pubDate>Fri, 15 Jan 2010 23:43:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.analogrithems.com/rant/?p=13#comment-1009</guid>
		<description>I do it like this
 function view( $id ){
      if(!empty($id)){
          $filter = $this-&gt;Person-&gt;primaryKey.&quot;=&quot;.$id;
          $people = $this-&gt;Person-&gt;find(&#039;first&#039;, array( &#039;conditions&#039;=&gt;$filter));
          $this-&gt;set(compact(&#039;people&#039;));
      }
}

And in my model I define my primary Key like this
        // This would be the ldap equivalent to a primary key if your dn is
        // in the format of uid=username, ou=people, dc=example, dc=com
        var $primaryKey = &#039;uid&#039;;

Note though that depending on what your trying to model you can change the primaryKey, sometimes you want to look at your objects holistically so the primaryKey would be &#039;dn&#039;.  Or if you are dealing with groups your primary key would be &#039;cn&#039;.  This takes a little getting used to.

In My view I can then access the cn like this
    &lt;?php echo $this-&gt;data[&#039;Person&#039;][&#039;cn&#039;]; ?&gt;</description>
		<content:encoded><![CDATA[<p>I do it like this<br />
 function view( $id ){<br />
      if(!empty($id)){<br />
          $filter = $this-&gt;Person-&gt;primaryKey.&#8221;=&#8221;.$id;<br />
          $people = $this-&gt;Person-&gt;find(&#8216;first&#8217;, array( &#8216;conditions&#8217;=&gt;$filter));<br />
          $this-&gt;set(compact(&#8216;people&#8217;));<br />
      }<br />
}</p>
<p>And in my model I define my primary Key like this<br />
        // This would be the ldap equivalent to a primary key if your dn is<br />
        // in the format of uid=username, ou=people, dc=example, dc=com<br />
        var $primaryKey = &#8216;uid&#8217;;</p>
<p>Note though that depending on what your trying to model you can change the primaryKey, sometimes you want to look at your objects holistically so the primaryKey would be &#8216;dn&#8217;.  Or if you are dealing with groups your primary key would be &#8216;cn&#8217;.  This takes a little getting used to.</p>
<p>In My view I can then access the cn like this<br />
    < ?php echo $this->data['Person']['cn']; ?></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: orangepeelbeef</title>
		<link>http://www.analogrithems.com/rant/2009/06/12/cakephp-with-full-crud-a-living-example/comment-page-1/#comment-1008</link>
		<dc:creator>orangepeelbeef</dc:creator>
		<pubDate>Fri, 15 Jan 2010 20:49:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.analogrithems.com/rant/?p=13#comment-1008</guid>
		<description>Aside from the schema it seems to be authenticating properly.  I see the user information gets dumped into the session data, but how do I access the ldap attributes?  I want to retrieve the email address the &#039;mail&#039; attribute, but i&#039;m not having much luck getting that info.  Should I be grabbing it out of the session or is there some trick for getting it via something like  $user[&#039;mail&#039;]  ?</description>
		<content:encoded><![CDATA[<p>Aside from the schema it seems to be authenticating properly.  I see the user information gets dumped into the session data, but how do I access the ldap attributes?  I want to retrieve the email address the &#8216;mail&#8217; attribute, but i&#8217;m not having much luck getting that info.  Should I be grabbing it out of the session or is there some trick for getting it via something like  $user['mail']  ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: orangepeelbeef</title>
		<link>http://www.analogrithems.com/rant/2009/06/12/cakephp-with-full-crud-a-living-example/comment-page-1/#comment-1007</link>
		<dc:creator>orangepeelbeef</dc:creator>
		<pubDate>Thu, 14 Jan 2010 01:54:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.analogrithems.com/rant/?p=13#comment-1007</guid>
		<description>Also,  Fwiw,  phpldapadmin can retrieve my AD schema with no modifications.  I only mention this because the __getLDAPschema() code mentions it was borrowed from phpldapadmin.  I assume it was borrowed a long time ago, and things have probably changed dramatically.</description>
		<content:encoded><![CDATA[<p>Also,  Fwiw,  phpldapadmin can retrieve my AD schema with no modifications.  I only mention this because the __getLDAPschema() code mentions it was borrowed from phpldapadmin.  I assume it was borrowed a long time ago, and things have probably changed dramatically.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
