I will login to the site when I get some more time and post examples - I'll have to de-API the code and make it more basic.... :) <br><br>function ldapConnect($type = false,$server = false) {
<br>// type can be 'admin' or 'user', function returns a connection object.
<br>// pass a name of a server string if you prefer a server to connect to.
<br>if(!is_callable('ldap_connect')) return false; <br>$connected = false;
<br>$tries = 0;
<br>while (!$connected) {
<br> $tries++;
<br> if(!empty($server)) {$lastId = $server['entry_id'];}
<br> else { $lastId = false; }
<br> $server = ldapServerArray(false,$server,$lastId);
<br> @$ldapConn = ldap_connect($server['host']);
<br> @ldap_set_option($ldapConn, LDAP_OPT_TIMELIMIT, DEFAULT_LDAP_QUERY_TIMEOUT);
<br> @ldap_set_option($ldapConn, LDAP_OPT_NETWORK_TIMEOUT, DEFAULT_LDAP_TIMEOUT);
<br> @ldap_set_option($ldapConn, LDAP_OPT_PROTOCOL_VERSION, 3);
<br> @ldap_set_option($ldapConn, LDAP_OPT_REFERRALS, 0);
<br> if($type == "admin") {
<br> $user = $server['admin_name'];
<br> $pass = $server['admin_pass'];
<br> }
<br> else {$user=$server['user_name']; $pass=$server['user_pass'];}
<br> if(@$ldapBind = ldap_bind($ldapConn,$user . '@' . $server['domain'],$pass)) {
<br> $connected = true;
<br> }
<br> elseif($tries >= SITE_LDAP_CONNECT_ATTEMPTS) { return false; } // if we have tried LDAP_MAX_CONNECTION_ATTEMPTS times to bind, quit - and stop hassling the Ldap Server
<br> else { ldap_close($ldapConn); }
<br>}
<br> return $ldapConn;
<br>}<br><br><div class="gmail_quote">On Thu, Jul 2, 2009 at 9:52 PM, Michael Mol <span dir="ltr"><<a href="mailto:mikemol@gmail.com">mikemol@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Thu, Jul 2, 2009 at 9:47 PM, Ben DeMott<<a href="mailto:ben.demott@gmail.com">ben.demott@gmail.com</a>> wrote:<br>
> Oh yeah, if that's what you are looking for I wrote a whole PHP api to do<br>
> common AD stuff like:<br>
> BaseSearchDn = (your DN)<br>
> function: adUserExists()<br>
> function: adGroupExists()<br>
> function: adIsGroupMember()<br>
><br>
> calculating the AD password reset time,<br>
> and converting the AD LDAP fields into COMMON ldap fields - oh the memories<br>
> :)<br>
><br>
> ... and LDAP (ad) API will actually come with OpenLEAF - but thats another<br>
> story.<br>
><br>
> I will round up some examples for ya :)<br>
<br>
</div>Feel free to create an account on the site, or even edit anonymously;<br>
It's an open-edit wiki. :-)<br>
<font color="#888888"><br>
<br>
--<br>
</font><div><div></div><div class="h5">:wq<br>
_______________________________________________<br>
grlug mailing list<br>
<a href="mailto:grlug@grlug.org">grlug@grlug.org</a><br>
<a href="http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug" target="_blank">http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug</a><br>
</div></div></blockquote></div><br>