At the moment I have the following in db.py:
if request.env.web2py_runtime_gae: # if running on Google App Engine
db = DAL('gae') # connect to Google BigTable
session.connect(request, response, db=db) # and store sessions and
tickets there
else: # else use a normal
relational database
db = DAL('sqlite://storage.sqlite') # if not, use SQLite or other DB
from gluon.contrib.login_methods.ldap_auth import ldap_auth
from gluon.tools import *
auth=Auth(globals(),db) # authentication/authorization
crud=Crud(globals(),db) # for CRUD helpers using auth
service=Service(globals()) # for json, xml, jsonrpc,
xmlrpc, amfrpc
auth.settings.login_methods=[ldap_auth(server='stbldap01.sun.ac.za',base_dn='ou=users,O=SU',
mode='cn', secure=True)]
auth.settings.table_user =
db.define_table("auth_user",db.Field("first_name",length=128,default=""),
db.Field("last_name", length=128,default=""),
db.Field("email", length=128,default=""),
db.Field("username", length=32,default=""),
db.Field("password",'password',readable=False, label="Password"),
db.Field("registration_key", length=128,
writable=False, readable=False, default=""))
t = auth.settings.table_user
t.first_name.requires = IS_NOT_EMPTY()
t.username.requires = IS_NOT_EMPTY()
t.last_name.requires = IS_NOT_EMPTY()
t.password.requires = CRYPT() # password will be stored hashed
t.email.requires = [IS_EMAIL(), IS_NOT_IN_DB(db, db.auth_user.email)]
t.username.requires = [IS_NOT_IN_DB(db, db.auth_user.username)]
auth.define_tables() ### auth_user will not be redefined!
crud.settings.auth=auth # enforces authorization on crud
mail=Mail() # mailer
mail.settings.server='localhost' # your SMTP server
mail.settings.sender='johann...@gmail.com' # your email
Now my question:
When I register a user I don't want the user to enter a password
because when the user logs in in future the password must be checked
against the hash in the LDAP tree. So when I register myself (with or
without a password on registration) I cannot log in afterwords. All
my logins ends with "Invalid login". How can I find out what went
wrong? Is ther some sort of log somewhere?
Regards
Johann
2009/8/3 Fran <franc...@googlemail.com>:
>> db.Field("password",'password',readable=False, label="Password"),
>
> Add writable=False to make it not show in the register form.
Thanks. I am learning...
>
> My guess is that this is an LDAP failure.
> Try the LDAP login from the CLI on the same machine as the server (to
> check for Firewall issues).
> The relevant string to test from what you have above is:
> ldapwhoami -x -D cn=username,ou=users,O=SU -W -H ldaps://stbldap01.sun.ac.za:389
> (replace 'username' with your username)
$ ldapwhoami -x -D 'cn=jspies,ou=users,O=SU' -W -H
ldaps://stbldap01.sun.ac.za:369
Enter LDAP Password:
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
and
$ ldapwhoami -x -D 'cn=jspies,ou=users,O=SU' -W -H ldaps://stbldap01.sun.ac.za
Enter LDAP Password:
ldap_parse_result: Protocol error (2)
additional info: Unrecognized extended operation
Result: Protocol error (2)
Additional info: Unrecognized extended operation
but
$ ldapwhoami -H ldaps://stbldap01.sun.ac.za -D
'cn=jspies,ou=users,O=SU' -x -v -W -n
Enter LDAP Password:
ldap_initialize( ldaps://stbldap01.sun.ac.za:636/??base )
ldap_sasl_interactive_bind_s: Unknown authentication method (-6)
>
> If you get a working LDAP connection string, then we can let you know
> how to do this within ldap-auth (which may require amending the ldap-
> auth to cater for the option(s) you need)
I hope the information above will help.
Thanks again.
Regards
Johann