lots of people have helped and are helping. welcome on board! it would be great if you could write an ldap howto on AlterEgo.
Massimo On Feb 11, 1:32 pm, Tincho <martinr...@gmail.com> wrote: > ups, you are rigth, thanks for the answer, i'm just begging with > web2py and it's increible easy to use. > Congratulations massimo, you did a really good work... > > On 10 feb, 11:42, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > Are you using the binary distribution of web2py? In this case it is > > using its own python and it does not see the libs installed with your > > other python. You may need to run from source. > > > Massimo > > > On Feb 10, 8:14 am, Tincho <martinr...@gmail.com> wrote: > > > > hi, i want to use ldap-python lib to authenticate against a server. I > > > want > > > to encapsulate this functionality in a module. I made a class called > > > LDAPService that uses ldap lib and i put on > > > web2py/applications/MyApp/modules/myModule.py. The problem is that > > > when i > > > want to import this module from a controller it raise an exception > > > because > > > could not import ldap library. Of course i previously installed the > > > lib. why > > > could not find the lib? Could anyone help me please? thanks in > > > advance.... > > > > PD: is there a way to implement services in web2py? > > > > Here's the controller code: > > > > def index(): > > > msg="" > > > form=FORM(TABLE( > > > TR(TD("Username"), TD(INPUT(_type="text", > > > _name="username",requires =IS_NOT_EMPTY()))), > > > TR(TD("Password"), TD(INPUT(_type='password', > > > _name="password", requires=IS_NOT_EMPTY()))), > > > TR(TD(""), TD(INPUT(_type="submit",_value="Login"))))) > > > if form.accepts(request.vars,session, 'loginform'): > > > import sys > > > from applications.MyApp.modules import myModule as myModule > > > username = form.vars.username > > > password = form.vars.password > > > #check if user exists > > > service = myModule.LDAPService() > > > allowentry = service.authenticateUser(username, password) > > > if allowentry: > > > redirect(URL(r=request, c='ldapmanager', f='index', > > > vars=dict(message=msg))) > > > return dict(message=msg, loginform=form) > > > > Here is the myModule.py code: > > > > import sys > > > try: > > > import ldap #Here crashes > > > except: raise Exception, 'This module requires LDAP' > > > > server = "localhost" > > > > class LDAPService: > > > > def authenticateUser(self, user, pw): > > > authenticate = false > > > msg="" > > > try: > > > l = ldap.initialize(server) > > > try: > > > l.bind_s("....."%user, pw) > > > msg="Succesfully connected!!" > > > authenticate = true > > > except ldap.INVALID_CREDENTIALS: > > > msg="Your username or password is incorrect." > > > sys.exit() > > > except ldap.LDAPError, e: > > > if type(e.message) == dict and e.message.has_key > > > ('desc'): > > > msg=e.message['desc'] > > > else: > > > msg=e > > > finally: > > > l.unbind() > > > return authenticate --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---