Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting Windows authentication? #18

Open
danchr opened this issue Sep 4, 2017 · 1 comment
Open

Supporting Windows authentication? #18

danchr opened this issue Sep 4, 2017 · 1 comment

Comments

@danchr
Copy link

danchr commented Sep 4, 2017

We have to use Windows authentication in production, but I see you removed support for using the original ADO driver in 31b1ffb. Perhaps because it was broken and tricky to actually use or test due to the dependancy on python-tdb?

It so happens I fixed it locally and got django-sqlserver up and running on Django 1.11 (which django-mssql doesn't support) with the ADO driver, only to pull and discover that you removed it.

So, my question is: Is it possible to use Windows authentication with the PyTDB driver, and if so, would you perhaps consider documenting it? If not, would you consider a patch to revive ADO support? After all, django-mssql doesn't seem all that active, and it'd be nice to use one driver everywhere.

@danchr
Copy link
Author

danchr commented Nov 24, 2017

Answering my own question, we settled on the following unholy hack:

    import functools, sys

    from sqlserver import base
    from pytds import login

    orig_gcp = base.DatabaseWrapper.get_connection_params_pytds

    @functools.wraps(orig_gcp)
    def get_connection_params_pytds(self):
        """Returns a dict of parameters suitable for get_new_connection."""
        conn_params = orig_gcp(self)

        conn_params['auth'] = login.SspiAuth(
            user_name=conn_params['user'],
            password=conn_params['password'],
            server_name=conn_params['server'],
            port=conn_params['port'],
        )
   
        return conn_params

    base.DatabaseWrapper.get_connection_params_pytds = \
        get_connection_params_pytds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant