<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
  <title>aC forum: LDAP database loging code snippet</title>
  <link>http://www.activecollab.com/forums/topic/2224/</link>
  <description>Recent posts on topic: LDAP database loging code snippet</description>
  <dc:language>en-us</dc:language>
  <pubDate>Tue, 02 Dec 2008 00:25:32 UTC</pubDate>
  
  <item>
    <link>http://www.activecollab.com/forums/post/11261/#post11261</link>
    <guid>http://www.activecollab.com/forums/post/11261/#post11261</guid>
    <title>Post #18 by RobDaPraia</title>
    <dc:creator>RobDaPraia</dc:creator>
    <description><![CDATA[<p>Thanks for the explanation, was looking for this to SSO into ActiveCollab.<br />
<br />
I just did the following on my Apache web server where authentication is done by the Apache web server and the user name is stored as a server variable &quot;PHP_AUTH_USER&quot;. Since this PHP_AUTH_USER is a user name and not an id, I had to add an extra field to the acx_users table: acx_users.username varchar 10, not null and to hack the file Users.class.php to create a function to search for the user by username.<br />
<br />
Users.class.php:<br />
<br />
/* Hacked by Rob */<br />
/* Extra function for SSO after authentication by Apache <br />
   this requires extra field in table acx_users.username varchar 10, not null<br />
<br />
    /**<br />
     * Return user by username<br />
     *<br />
     * @param string $username<br />
     * @return User<br />
     */<br />
    function findByUserName($username) {<br />
      return Users::find(array(<br />
        'conditions' =&gt; 'username = ' . db_escape($username),<br />
        'one' =&gt; true,<br />
      ));<br />
    } // findByUserName<br />
    <br />
<br />
/* End of Hacked by Rob */<br />
<br />
<br />
For authentication I made the following class, based on the article in the knowledge base:<br />
<br />
&lt;?php<br />
<br />
<br />
class ApacheAuthenticationProvider extends AuthenticationProvider {<br />
<br />
  function initialize() {<br />
<br />
    $user = Users::findByUserName($_SERVER['PHP_AUTH_USER']);<br />
<br />
    if(instance_of($user, 'User')) {<br />
      return $this-&gt;logUserIn($user);<br />
    } else {<br />
      return new Error('User not recognized');<br />
    } // if<br />
  } // initialize<br />
<br />
}<br />
<br />
?&gt;<br />
<br />
<br />
<br />
</p>]]></description>
    <pubDate>Sun, 30 Dec 2007 19:11:47 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/11178/#post11178</link>
    <guid>http://www.activecollab.com/forums/post/11178/#post11178</guid>
    <title>Post #17 by colin.hostert</title>
    <dc:creator>colin.hostert</dc:creator>
    <description><![CDATA[<p>Has anyone had any success getting this to work against an openLDAP directory ? </p>]]></description>
    <pubDate>Thu, 20 Dec 2007 06:22:32 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/11031/#post11031</link>
    <guid>http://www.activecollab.com/forums/post/11031/#post11031</guid>
    <title>Post #16 by phodgdon</title>
    <dc:creator>phodgdon</dc:creator>
    <description><![CDATA[<p>Nevermind, I see your zip file.  Thanks.</p>]]></description>
    <pubDate>Wed, 05 Dec 2007 02:39:31 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/11030/#post11030</link>
    <guid>http://www.activecollab.com/forums/post/11030/#post11030</guid>
    <title>Post #15 by phodgdon</title>
    <dc:creator>phodgdon</dc:creator>
    <description><![CDATA[<p>Casper - I was able to use the adLDAP library and get it so i can authenticate off Active Directory using the example, how did you then incorporate that into the authentication for activeCollab?  Did you use the method that Ilija mentioned in his documentation?</p>]]></description>
    <pubDate>Wed, 05 Dec 2007 02:38:23 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/10945/#post10945</link>
    <guid>http://www.activecollab.com/forums/post/10945/#post10945</guid>
    <title>Post #14 by Valdemar</title>
    <dc:creator>Valdemar</dc:creator>
    <description><![CDATA[<p>I got the error message: &quot;Failed to create an account. Reason: Failed to validate model properties&quot; with my $user_data array for some odd reason - I couldn't figure out why. However, by doing it exactly as you did, it works!<br />
<br />
It now automatically creates new users, assigns them to a company and gives them a role. Excellent.<br />
<br />
Get it here: <a href="http://fatty.dk/acadauthprovider.zip" target="_blank" rel="nofollow">http://fatty.dk/acadauthprovider.zip</a><br />
<br />
Thanks.</p>]]></description>
    <pubDate>Wed, 28 Nov 2007 16:26:49 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/10943/#post10943</link>
    <guid>http://www.activecollab.com/forums/post/10943/#post10943</guid>
    <title>Post #13 by Ilija Studen</title>
    <dc:creator>Ilija Studen</dc:creator>
    <description><![CDATA[<p>We added that article just recently. <br />
<br />
As a side note: save() method returns true if everything went fine or an Error instance in case of error with all the details - error message, parameters, where it was thrown etc.</p>]]></description>
    <pubDate>Wed, 28 Nov 2007 14:45:36 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/10942/#post10942</link>
    <guid>http://www.activecollab.com/forums/post/10942/#post10942</guid>
    <title>Post #12 by Valdemar</title>
    <dc:creator>Valdemar</dc:creator>
    <description><![CDATA[<p>I completely missed that part :)  Guess I need glasses. Looks the same as what I've already tried, after looking in UserProfileController.class.php. I created the User object fine, but then tried doing a -&gt;save(), but nothing was written to the db, not even an error. I'll look into it when I get the time.</p>]]></description>
    <pubDate>Wed, 28 Nov 2007 14:37:46 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/10941/#post10941</link>
    <guid>http://www.activecollab.com/forums/post/10941/#post10941</guid>
    <title>Post #11 by Ilija Studen</title>
    <dc:creator>Ilija Studen</dc:creator>
    <description><![CDATA[<p>Hi Casper,<br />
<br />
Have you checked out <a href="http://www.activecollab.com/support/index.php?pg=kb.page&amp;id=38" target="_blank" rel="nofollow"> Overriding / Extending activeCollab Authentication</a> knowledge base entry? In code examples you have a peace that create a new user in activeCollab database. It works - tested.</p>]]></description>
    <pubDate>Wed, 28 Nov 2007 14:32:10 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/10940/#post10940</link>
    <guid>http://www.activecollab.com/forums/post/10940/#post10940</guid>
    <title>Post #10 by phodgdon</title>
    <dc:creator>phodgdon</dc:creator>
    <description><![CDATA[<p>Great thanks!  We do have a lot of users with aliases and we also have 2 email systems so it makes it a challenge, but this should work.</p>]]></description>
    <pubDate>Wed, 28 Nov 2007 13:27:35 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/10936/#post10936</link>
    <guid>http://www.activecollab.com/forums/post/10936/#post10936</guid>
    <title>Post #9 by Valdemar</title>
    <dc:creator>Valdemar</dc:creator>
    <description><![CDATA[<p>Okay, polished it a bit. This is for Active Directory using the great <a href="http://adldap.sourceforge.net/" target="_blank" rel="nofollow">adLDAP</a> library by Scott Barnett. Please be sure that your Apache has mod_ldap working and installed. You can use the example.php in the adLDAP distribution to test the connection to your AD.<br />
<br />
<a href="http://fatty.dk/acadauthprovider.zip" target="_blank" rel="nofollow">http://fatty.dk/acadauthprovider.zip</a><br />
<br />
^ That would be the authentication provider. Be sure to read the README and INSTALL - it's pretty basic stuff really. You still log on with your e-mail address - but remember, the e-mail username (username@bla.com) HAS to be the same as the AD username (username@bla.local). Beware of this, since it's not always the same. For instance, if your user uses an e-mail alias or different e-mail, than for logon.<br />
<br />
*** Automatic user creation is not working (when as user is not created in aC, but authenticates in AD). I seem to be able to create the object fine, but it won't save it to the database using $this-&gt;new_user-&gt;save(). Any ideas or help would be appreciated. But for now, it does what it's supposed to, log people on. *** UPDATE: It's working now, just grab the zip again.<br />
<br />
Beware that it falls back to the standard basic authentication, so passwords set in aC still work! (this may change when I can update the password using the API).<br />
<br />
Enjoy.</p>]]></description>
    <pubDate>Wed, 28 Nov 2007 11:13:42 UTC</pubDate>
  </item>
</channel>
</rss>