Skip to content
Snippets Groups Projects
Commit a7d2cc3e authored by Lars Seipel's avatar Lars Seipel
Browse files

connector/ldap: adjust attributes for h_da directory

parent 0dbc9716
No related branches found
No related tags found
No related merge requests found
......@@ -410,7 +410,7 @@ func (c *ldapConnector) identityFromEntry(user ldap.Entry) (ident connector.Iden
err := fmt.Errorf("ldap: entry %q missing following required attribute(s): %q", user.DN, missing)
return connector.Identity{}, err
}
return ident, nil
return tweakIdentity(ident), nil
}
func (c *ldapConnector) userEntry(conn *ldap.Conn, username string) (user ldap.Entry, found bool, err error) {
......
package ldap
import (
"strings"
"github.com/dexidp/dex/connector"
)
// TweakIdentity adjusts attributes received from the LDAP directory. Don't ask
// why this is necessary. Just learn to accept it.
func tweakIdentity(id connector.Identity) connector.Identity {
id.Username = tweakName(id)
return id
}
func tweakName(id connector.Identity) string {
name := id.Username
if name == " " {
return id.PreferredUsername
}
xs := strings.Split(name, ", ")
if len(xs) == 1 {
return name
}
if strings.Contains(xs[1], " (") {
xs[1] = strings.Split(xs[1], " (")[0]
}
return xs[1] + " " + xs[0]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment