go-mssqldb
go-mssqldb copied to clipboard
Windows Authentication with user id in the "DOMAIN\User" format does not function
I'm working with the following project which makes use of this library and I'm unable to get Windows Authentication functioning: https://github.com/free/sql_exporter
It appears that the reason sql_exporter isn't working for me is due to an issue in go-mssqldb. Right at the top of the README.md for this project it says "Windows Authentication user id in the DOMAIN\User format". But then this happened:
https://go-review.googlesource.com/c/go/+/87038
Consider the following DSN for Windows Authentication:
'sqlserver://MYCOMPANYDOMAIN\bob.jones@SQL-SERVER'
This produces the error "net/url: invalid userinfo" which is coming from that updated validation code that does not support the "" character, a character your README says to use.
Further, please provide a DSN example for Windows Authentication in your README, you have a lot of SQL Authentication examples and no Windows Authentication examples even though you claim to support it.
Thanks.
Those are fair points. I wasn't even aware of the mentioned CL. We should probably see about adding a test for this and updating the README.
For anyone bumping into this, it looks like replacing the \
with the %5C
escape sequence works. So sqlserver://MYCOMPANYDOMAIN\bob.jones@SQL-SERVER
needs to be rewritten as sqlserver://MYCOMPANYDOMAIN%5Cbob.jones@SQL-SERVER
.
@kardianos Would you be interested in having some code in this project which escapes the backslash character in the connection string, so users won't have to do that themselves?
Can we include @mihaitodor fix or it was already? Lucky with this thread that solved a long time problem for me, forced to use instead sql authentication.