Skip to content

Commit

Permalink
try to fix ladp group missing members
Browse files Browse the repository at this point in the history
  • Loading branch information
shankerwangmiao committed Dec 7, 2023
1 parent 027ab3d commit 233e1d8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ func handleSearch(w ldap.ResponseWriter, m *ldap.Message) {
e.AddAttribute("loginShell", ldapMsg.AttributeValue(u.LoginShell))
e.AddAttribute("homeDirectory", ldapMsg.AttributeValue(fmt.Sprintf("/home/%s", u.Username)))
e.AddAttribute("userPassword", ldapMsg.AttributeValue(u.Password))
e.AddAttribute("objectClass", "top")
e.AddAttribute("objectClass", "posixAccount")
e.AddAttribute("objectClass", "shadowAccount")
e.AddAttribute("objectClass", "top", "posixAccount", "shadowAccount")
e.AddAttribute("shadowMax", "99999")
w.Write(e)
}
Expand All @@ -192,11 +190,12 @@ func handleSearch(w ldap.ResponseWriter, m *ldap.Message) {
e := ldap.NewSearchResultEntry(fmt.Sprintf("cn=%s,ou=groups,%s", g.Name, dcfg.LDAP.Suffix))
e.AddAttribute("cn", ldapMsg.AttributeValue(g.Name))
e.AddAttribute("gidNumber", ldapMsg.AttributeValue(strconv.Itoa(g.GID)))
members := []ldapMsg.AttributeValue{}
for _, username := range g.Members {
e.AddAttribute("memberUid", ldapMsg.AttributeValue(username))
members = append(members, ldapMsg.AttributeValue(username))
}
e.AddAttribute("objectClass", "top")
e.AddAttribute("objectClass", "posixGroup")
e.AddAttribute("memberUid", members...)
e.AddAttribute("objectClass", "top", "posixGroup")
w.Write(e)
}
}
Expand Down

0 comments on commit 233e1d8

Please sign in to comment.