I am using ldap-authentication and it seems that a successful login
against the ldap-tree results in automatic access to the system as a
registered user.

I do not want that.  How can I redirect login to the registration
function if a non-existing user tries to login?

I have the following authentication model:

auth=Auth(globals(),db)                      # authentication/authorization
auth_table = db.define_table(
    auth.settings.table_user_name,
    Field('first_name', length=128, default=''),
    Field('last_name', length=128, default=''),
    Field('birthdate', 'date'),
    Field('email', length=128, default='', unique=True),
    Field('username',length=128, unique=True),
    Field('taalvoorkeur', length=25, default='Afrikaans'),
    Field('password', 'password', length=256,
          readable=False, label='Password'),
    Field('registration_key', length=128, default= '',
          writable=False, readable=False))

auth_table.first_name.requires = \
    IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_table.last_name.requires = \
    IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_table.password.requires = [IS_STRONG(), CRYPT()]
auth_table.email.requires = [
    IS_EMAIL(error_message=auth.messages.invalid_email),
    IS_NOT_IN_DB(db, auth_table.email)]
auth_table.username.requires = IS_NOT_IN_DB(db, auth_table.username)
auth_table.taalvoorkeur.requires = IS_IN_SET(('Afrikaans', 'English'))
auth.settings.table_user = auth_table
auth.settings.registration_requires_approval = True
auth.settings.actions_disabled.append('change_password')
auth_table.birthdate.requires = \
    IS_NOT_EMPTY(error_message=auth.messages.is_empty)

auth.settings.login_methods=[ldap_auth(server='stbldap01.sun.ac.za',
port=636, base_dn='ou=users,O=SU', mode='cn', secure=True)]
auth.settings.hmac_key='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
auth.define_tables()                         # creates all needed tables
from gluon.tools import Crud
crud=Crud(globals(),db)                      # for CRUD helpers using auth
service=Service(globals())                   # for json, xml, jsonrpc,
xmlrpc, amfrpc

crud.settings.auth=auth                      # enforces authorization on crud

Regards
Johann

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to