While trying to answer a question on StackOverflow
(http://stackoverflow.com/questions/7962840/web2py-ms-sql-server-2008-r2-ldap-authentication-helloworld-application)
I found the potential need for a patch to dal.py. The DAL works just fine
if you want to connect to MSSQL using SQL Server's authentication, but
doesn't currently work to well if you want to authenticate to the DB using
windows authentication. The fix is fortunately pretty simple
In gluon/dal.py just do (starting at line 2154 in trunk)
m =
re.compile('^(?P<user>[^:@]+)(\:(?P<password>[^@]*))?@(?P<host>[^\:/]+)(\:(?P<port>[0-9]+))?/(?P<db>[^\?]+)(\?(?P<urlargs>.*))?$').match(uri)
if not m:
raise SyntaxError, \
"Invalid URI string in DAL: %s" % uri
user = credential_decoder(m.group('user'))
if not user:
raise SyntaxError, 'User required'
#patch to help get windows based authentication working
if user == 'NONE':
user = ''
#end patch
which then lets you connect with:
db = DAL('mssql://NONE@db_server/database_name?Trusted_Conection=Yes')
Or a better option might be to change it so that when the username is
"NONE" or perhaps "WINDOWS_AUTH" the dal would automatically know the
username should be blank and add in the Trusted_Connection=Yes argument.