-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Enable IntegratedAuthentication (ActiveDirectory) for MSSQL #5349
Comments
I don't think driver supports integrated authentication |
To use AD auth you still need to provide username and password |
I created some test code which uses xorm to select the username and the version of a sql-server. I connected only using package main
import (
"fmt"
"log"
_ "github.com/denisenkom/go-mssqldb"
"github.com/go-xorm/core"
"github.com/go-xorm/xorm"
)
var engine *xorm.Engine
func main() {
var err error
var sql string
var res []map[string]string
engine, err = xorm.NewEngine("mssql", "server=<server>;database=<database>")
if err != nil {
log.Fatal(err)
}
engine.ShowSQL(true)
engine.Logger().SetLevel(core.LOG_DEBUG)
sql = "select current_user as usr,@@version ver"
res, err = engine.QueryString(sql)
if err != nil {
log.Fatal(err)
}
for _, element := range res {
// index is the index where we are
// element is the element from someSlice for where we are
fmt.Println(element)
}
engine.Close()
} result map[usr<winUsername> ver:Microsoft SQL Server 2014 (SP3) (KB4022619) - 12.0.6024.0 (X64)
Sep 7 2018 01:37:51
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor)
] It would be nice if I could use this in gitea, too. |
So if there is an config on ini file to enable integration login when MSSQL used. Then we only need to put username and password empty. Is that OK? |
I checked if you can simply leave engine, err = xorm.NewEngine("mssql", "server=<server>;database=<database>;user id=;password=") It still works.
I think a simple switch in the config file or just letting me pass no "user id" and/or "password" should to it. |
@road42 could you send a PR for that? |
I'd like to, but I am no go developer this is just a feature-request :) |
I just set up Gitea 1.22.0 with MSSQL and Windows Integrated Authentication without problems. My database configuration is
It works like a charm. I think this issue can be closed as the feature is working. |
[x]
):Description
I'd like to use the integrated authentication for a mssql database. I already looked into the sourcecode:
On this line the connectionString is created:
gitea/models/models.go
Line 239 in 127f477
It seems that gitea uses xorm as or-mapper.
xorm uses the mssql-driver from: https://github.com/denisenkom/go-mssqldb
The driver has the following documentation:
Solution?
I already tried to leave "user id" and/or "password" in the configuration empty, but it did not connect to the database.
It should be possible to leave the password and username field empty to connect to a mssql database.
The text was updated successfully, but these errors were encountered: