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

[QUESTION] Connecting using "domain credentials" #353

Open
djl0 opened this issue Feb 23, 2024 · 5 comments
Open

[QUESTION] Connecting using "domain credentials" #353

djl0 opened this issue Feb 23, 2024 · 5 comments
Labels
question Further information is requested

Comments

@djl0
Copy link

djl0 commented Feb 23, 2024

Hi everyone - I'm running myself in circles, and I was hoping someone might be able to shed some light on my situation. The credentials I was given from the DB admin was in the form of "domain\username". When I connect in Pycharm, it uses what it calls "domain credentials". I'm using a python-slim docker image and ODBC Driver 17. In my settings.py, I've tried every combination of domain and username in the user, host, instance fields with no success (still getting "login failed"). I saw an issue (linked below) where someone said "windows authentication" doesn't work; is my auth-style that? Or I'm seeing these extra flags that refer to Active directory.

Any help is greatly appreciated.

Relevant Issues and Pull Requests
Is this the same issue as here?
That refers to this: https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-containers-ad-auth-adutil-tutorial?view=sql-server-ver16

@djl0 djl0 added the question Further information is requested label Feb 23, 2024
@mShan0
Copy link
Contributor

mShan0 commented Feb 27, 2024

It seems like you're using Windows authentication based on the "domain\username" format. Does your machine have permissions to connect to your database?

The issue you linked is not related unless your SQL server is running on a Linux-based machine.

@dauinsight
Copy link
Contributor

If you are using windows authentication, please remove the "USER" and "PASSWORD" field.

@mShan0 mShan0 reopened this Feb 27, 2024
@djl0
Copy link
Author

djl0 commented Feb 27, 2024

@mShan0 @dauinsight Thanks for your replies!

It seems like you're using Windows authentication based on the "domain\username" format. Does your machine have permissions to connect to your database?

I can connect using Pycharm (not in the docker container), so I would think so. The Pycharm connection parameters look pretty basic (ie there aren't any extra flags that I can see, aside from the authentication being "domain credentials").

If you are using windows authentication, please remove the "USER" and "PASSWORD" field.

Then how would I pass the USER & PASSWORD? I took those parameters out, and the message was No Kerberos Credentials Available

Another question: Should the domain in domain\username be domain in the extra parameters string?

Thanks!

@mShan0
Copy link
Contributor

mShan0 commented Feb 27, 2024

Your DATABASES should look something like this

DATABASES = {
    "default": {
        "ENGINE": "mssql",
        "NAME": "my_database_name",
        "USER": "DOMAIN\\username", # 2 of "\" to escape the character
        "HOST": "localhost", # or DB's IP address
        "PORT": "1433",
        "OPTIONS": {"driver": "ODBC Driver 18 for SQL Server", 
                    "extra_params": "Trusted_Connection=Yes;"},
    },
}

Did connecting with PyCharm only work when you provided a password?

@djl0
Copy link
Author

djl0 commented Feb 28, 2024

I tried the database parameters above (though I have ODBD Driver 17 installed), and I still got the same No Kerberos Credentials available error. And I did have to use the password when using Pycharm.

I'm thinking of creating a FreeTDS docker container to give that a try. I believe the server is SQL Server 11 (2012?), would that mean I should use an earlier driver, or would FreeTDS be a better option?

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

No branches or pull requests

3 participants