[Zope] RE: LoginManager and LDAP

Corey Zimmet caz@tcdi.com
Wed, 21 Feb 2001 12:39:03 -0500


I was able to do a basic test with LoginManager and
ZLDAPConnection/ZLDAPMethods using Zope 2.2.4:

In UserSource added these Python Methods:
------------------------------------------
userAuthenticate:
   parameter list: self,REQUEST,username,password

   function body:
return self.ldapAuthenticate(username,password)

-------------------------------------------
userDomains:
   parameter list: self, REQUEST, username

   function body:
# I don't use this for my ldap implementation
return []

-------------------------------------------
userExists:
   parameter list: self,REQUEST,username

   function body:
return 1

-------------------------------------------
userRoles:
   parameter list: self, REQUEST, username

   function body:
# call ldap method to get information on user
results=self.getUserInfo(uid=username)
row=results[0]
return row.get('roles')

-------------------------------------------
ldapAuthenticate:
  parameter list: self,username,password

  function body:
# call ldap method to get information on user
results=self.getUserInfo(uid=username)
# an external method that returns an md5 encrypted password
password=self.md5_encrypt(password)
if len(results)==0:
   return 0
elif len(results)>1:
   return 0
else:
   row=results[0]
   # userpassword is the name for the password in the ldap directory
   if row.get('userpassword')[0]=="{MD5}%s"%(password,):
      return 1
   else:
      return 0
---------------------------------------------


Added this LDAPMethod:
------------------------------------
getUserInfo:

parameter list: uid
query filter: uid=&dtml-uid;

---------------------------------------------

Hope this helps,
Corey