Description
Hi guys. First of all, gogs is awesome!
I'm trying to hook it into LDAP at a company. The problems is, I need to use simple LDAP so they login user ("%s") is passed into the LDAP bind credentials (can't store a hard-coded user).
For this, I set the User DN to be DOM\%s
, where DOM
is the AD domain and the login name in gogs is used as the username for AD. So when a user bob
logs into gogs, the ldap binds with his credentials and prepends the domain, i.e. DOM\bob
. By doing this, the bind (authentication to the AD server) works.
But the actual query to AD FAILS because the "CN" part of the AD query needs to be in a different format. Gogs seems to re-use the DOM\bob
as part of the query, but our servers use Lastname, Firstname
instead.
I can reproduce the situation using ldapsearch.
If I do
# uses Lastname and Fistname in query, but DOMAIN\username for binding
ldapsearch -h my.domain.server.com -p 123 -x -b "CN=Builder\, Bob,OU=Users,DC=blah,DC=blah,DC=blah,DC=com" -D "DOM\bob" -W
then I will retrieve the user successfully.
But the simple LDAP settings in gogs force me to use the DOM\bob
(via the login screen) as the "CN" part of the query, so it seems to be sending
# uses DOMAIN\username in both query and bind
ldapsearch -h my.domain.server.com -p 123 -x -b "CN=DOM\bob,OU=Users,DC=blah,DC=blah,DC=blah,DC=com" -D "DOM\bob" -W
and the output is an error from the AD server.
LdapErr: DSID-0C09076F, comment: Error processing name, data 0, v2580
I have verified that when I use the BindDN authentication with my credentials hard-coded for the bind, gogs authenticates fine against our AD servers, just as I would expect. But I do not want to use a single persons credentials for this purpose. I want to pass through the username and password from the gogs login for bind in LDAP. When I try to do that in BindDN, it doesn't seem to pass through the username and password via the %s
token ( a password token would be needed, too) as it does in simple DN. So I'm stuck.
When I use BindDN, I have to hard-code my credentials in order to successfully bind to LDAP, which I don't want to do.
If I want to pass through user/pass from gogs login, I have to use simple DN, but in that case my query is broken.
What can I do here?