From f3d3a387614dada07186bfa2a46c419404372636 Mon Sep 17 00:00:00 2001 From: Ben Yanke Date: Wed, 11 Apr 2018 10:41:54 -0500 Subject: [PATCH] Implement givenName and SN (first and last name) --- configbackend.go | 10 ++++++++++ glauth.go | 2 ++ 2 files changed, 12 insertions(+) diff --git a/configbackend.go b/configbackend.go index 7e1dc6d..5f74719 100644 --- a/configbackend.go +++ b/configbackend.go @@ -132,6 +132,16 @@ func (h configHandler) Search(bindDN string, searchReq ldap.SearchRequest, conn attrs := []*ldap.EntryAttribute{} attrs = append(attrs, &ldap.EntryAttribute{"cn", []string{u.Name}}) attrs = append(attrs, &ldap.EntryAttribute{"uid", []string{u.Name}}) + + if len(u.GivenName) > 0 { + attrs = append(attrs, &ldap.EntryAttribute{"givenName", []string{u.GivenName}}) + } + + if len(u.SN) > 0 { + attrs = append(attrs, &ldap.EntryAttribute{"sn", []string{u.SN}}) + } + + attrs = append(attrs, &ldap.EntryAttribute{"ou", []string{h.getGroupName(u.PrimaryGroup)}}) attrs = append(attrs, &ldap.EntryAttribute{"uidNumber", []string{fmt.Sprintf("%d", u.UnixID)}}) diff --git a/glauth.go b/glauth.go index 913dd56..b036366 100644 --- a/glauth.go +++ b/glauth.go @@ -77,6 +77,8 @@ type configUser struct { UnixID int Mail string LoginShell string + GivenName string + SN string } type configGroup struct { Name string