Commit 3ae8fb58 authored by ale's avatar ale
Browse files

Get UIDs from LDAP (where present)

parent 9dc319af
Pipeline #1064 passed with stages
in 1 minute and 27 seconds
......@@ -3,6 +3,7 @@ package backend
import (
"errors"
"fmt"
"strconv"
"strings"
"gopkg.in/ldap.v2"
......@@ -256,6 +257,7 @@ func (h *websiteResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Res
parentSite := entry.GetAttributeValue("parentSite")
name := fmt.Sprintf("%s/%s", parentSite, alias)
url := fmt.Sprintf("https://www.%s/%s/", parentSite, alias)
uid, _ := strconv.Atoi(entry.GetAttributeValue(uidNumberLDAPAttr))
username, err := getParentRDN(entry.DN, "uid")
if err != nil {
......@@ -270,6 +272,7 @@ func (h *websiteResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Res
Name: name,
Website: &accountserver.Website{
URL: url,
UID: uid,
ParentDomain: parentSite,
Options: entry.GetAttributeValues("option"),
DocumentRoot: entry.GetAttributeValue("documentRoot"),
......@@ -324,6 +327,8 @@ func (h *domainResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Reso
if err != nil {
return nil, err
}
uid, _ := strconv.Atoi(entry.GetAttributeValue(uidNumberLDAPAttr))
return &accountserver.Resource{
ID: accountserver.NewResourceID(
accountserver.ResourceTypeDomain,
......@@ -333,6 +338,7 @@ func (h *domainResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Reso
Name: cn,
Website: &accountserver.Website{
URL: fmt.Sprintf("https://%s/", cn),
UID: uid,
Options: entry.GetAttributeValues("option"),
DocumentRoot: entry.GetAttributeValue("documentRoot"),
AcceptMail: s2b(entry.GetAttributeValue("acceptMail")),
......@@ -385,6 +391,7 @@ func (h *webdavResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Reso
if err != nil {
return nil, err
}
uid, _ := strconv.Atoi(entry.GetAttributeValue(uidNumberLDAPAttr))
return &accountserver.Resource{
ID: accountserver.NewResourceID(
accountserver.ResourceTypeDAV,
......@@ -394,6 +401,7 @@ func (h *webdavResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Reso
Name: name,
DAV: &accountserver.WebDAV{
Homedir: entry.GetAttributeValue("homeDirectory"),
UID: uid,
},
}, nil
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment