Web2py + MS SQL Server 2008 R2 + LDAP Authentication HelloWorld application?
Question: I have been using Web2py in the awesome *nix environment for sometime along
with opensource RDMS (MySQL,Postgre,SQLLite,etc) for my personal projects.

For my workplace which is completely working in a .Net environment I need to
make a quick web app (employee master data maintenance) which runs on the
local intranet with authentication and user roles.

I planned to develop the application on web2py and deploy it on the default
rocket server BUT am stuck with the DAL. I have tried pyodbc, mssql, mssql2
adapters and all work arounds people have done on the google Group and other
forums.

My production and deployment environment details are:

O/S: MS Windows Server 2008  
DB: MS SQL Server 2008 R2 (hosted over LAN and with Windows Authentication not
SQL Authentication)  
Python: 2.7  
WebServer: IIS 7.0 ideally but I can work on Rocket.  

Is there any 'HelloWorld' application tutorial out there which covers these
topics:

  1. Windows Domain Authentication with user roles in Web2py
  2. Web2py-to-MSSQLServer2008R2 DAL
  3. Web2py-IIS7.0 Deployment

If someone can help me I can post this as a web2py appliance once I am done.


Answer: This is a partial answer, it only deals with authentication using Active
Directory (I assuma it is the same or similar to Domain Authentication). I am
not a Windows expert, but had the local windows admin help me. This is code
that I put in the db.py file for this app in web2py.

    
    
    if localauth:
        # I set localauth to 1 when using the app on my home lan, else 0
        # I am a consultant and not always connected to the client VPN
        # FYI, I do have a db of same type and name with same user/pw at home
        # in this case use the basic login that comes as default with web2py
        pass
    else:
        from gluon.contrib.login_methods.ldap_auth import ldap_auth
        auth.settings.login_methods = [ldap_auth(mode='ad',
                                                 server='<server ip address>',
                                                 base_dn='<base_dn>')]
        # the above line forces active directory to be the ONLY authentication method
    # my base_dn looked like this: 'OU=<ou>,DC=<subdomain>,DC=<domain>,DC=<tld e.g. com, net, edu, etc.>'
    # an active directory knowledgeable person can help you here
    

Jay

