/[docman2]/htusers/ldap.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /htusers/ldap.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sat Jul 20 13:07:24 2002 UTC (21 years, 10 months ago) by dpavlin
Branch: MAIN
Branch point for: DbP
Initial revision

1 dpavlin 1.1 <?
2    
3     /*
4     Document manager handling for users in LDAP
5     Created by Will LaSala (will@dahome.org)
6     February 10th, 2002
7     Belenos INC
8     For use with the DocMgr PHP scripts
9    
10     arguments in docman.conf file are:
11     $ldapServer="x.x.x.x"; This can be in Dotted Notation or a DNS FQN
12     $ldapServerPort="389"; This is the default port and doesnt need to be changed
13     $basedn="o=CompanyName"; Branch of tree that your search will start on
14     $bind="cn=Manager, o=CompanyName"; Login that allows password searching
15     $bindpw=""; Password for the above account
16    
17     LDAP query must return login, password full_name and e-mail
18     In order to do this it may be possible that you may need to modify a section of
19     the code below, however this is highly unlikly and usually only a person
20     that has in-depth knowledge of thier LDAP tree structure will
21     even know if they do have to make changes.
22     The items that may need to changed are:
23     $entries[0]["cn"][0]; This should return the Full Name
24     $entries[0]["userpassword"][0]; This should return the Password
25     $entries[0]["mail"][0]; This should return the Email
26    
27     This file is included early in docman.php and it should return:
28     $gblUserName descriptive username
29     $secHash md5 hash of joint login and password
30     $gblEmail e-mail address of user
31    
32     */
33    
34     if ($ds = ldap_connect_bind($bind, $bindpw, $ldapServer, $ldapServerPort)) {
35     $sres = ldap_search($ds, $basedn, "uid=".$GLOBALS[gblLogin]);
36     If ($sres) {
37     $entries = ldap_get_entries($ds, $sres);
38     $gblUserName = $entries[0]["cn"][0]; //Full Name
39     // FIX : it should return md5, right (Dobrica)
40     $secHash = $entries[0]["userpassword"][0]; //Password
41     $gblEmail = $entries[0]["mail"][0]; //Email
42     }else{
43     Error("Not Found","LDAP Search returned false");
44     }
45     ldap_close($ds);
46     }
47    
48    
49     function ldap_connect_bind($bindRDN, $bindpass, $ldapServer, $ldapServerPort) {
50     $linkid = ldap_connect($ldapServer, $ldapServerPort);
51     if ($linkid) {
52     if (!ldap_bind($linkid, $bindRDN, $bindpass)) {
53     Error("LDAP BIND","Unable to bind to LDAP server!");
54     return 0;
55     } else {
56     return $linkid;
57     }
58     } else {
59     Error("LDAP CONNECT","Unable to connect to LDAP server!");
60     return 0;
61     }
62     }
63     ?>

  ViewVC Help
Powered by ViewVC 1.1.26