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 ...@@ -3,6 +3,7 @@ package backend
import ( import (
"errors" "errors"
"fmt" "fmt"
"strconv"
"strings" "strings"
"gopkg.in/ldap.v2" "gopkg.in/ldap.v2"
...@@ -256,6 +257,7 @@ func (h *websiteResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Res ...@@ -256,6 +257,7 @@ func (h *websiteResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Res
parentSite := entry.GetAttributeValue("parentSite") parentSite := entry.GetAttributeValue("parentSite")
name := fmt.Sprintf("%s/%s", parentSite, alias) name := fmt.Sprintf("%s/%s", parentSite, alias)
url := fmt.Sprintf("https://www.%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") username, err := getParentRDN(entry.DN, "uid")
if err != nil { if err != nil {
...@@ -270,6 +272,7 @@ func (h *websiteResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Res ...@@ -270,6 +272,7 @@ func (h *websiteResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Res
Name: name, Name: name,
Website: &accountserver.Website{ Website: &accountserver.Website{
URL: url, URL: url,
UID: uid,
ParentDomain: parentSite, ParentDomain: parentSite,
Options: entry.GetAttributeValues("option"), Options: entry.GetAttributeValues("option"),
DocumentRoot: entry.GetAttributeValue("documentRoot"), DocumentRoot: entry.GetAttributeValue("documentRoot"),
...@@ -324,6 +327,8 @@ func (h *domainResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Reso ...@@ -324,6 +327,8 @@ func (h *domainResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Reso
if err != nil { if err != nil {
return nil, err return nil, err
} }
uid, _ := strconv.Atoi(entry.GetAttributeValue(uidNumberLDAPAttr))
return &accountserver.Resource{ return &accountserver.Resource{
ID: accountserver.NewResourceID( ID: accountserver.NewResourceID(
accountserver.ResourceTypeDomain, accountserver.ResourceTypeDomain,
...@@ -333,6 +338,7 @@ func (h *domainResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Reso ...@@ -333,6 +338,7 @@ func (h *domainResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Reso
Name: cn, Name: cn,
Website: &accountserver.Website{ Website: &accountserver.Website{
URL: fmt.Sprintf("https://%s/", cn), URL: fmt.Sprintf("https://%s/", cn),
UID: uid,
Options: entry.GetAttributeValues("option"), Options: entry.GetAttributeValues("option"),
DocumentRoot: entry.GetAttributeValue("documentRoot"), DocumentRoot: entry.GetAttributeValue("documentRoot"),
AcceptMail: s2b(entry.GetAttributeValue("acceptMail")), AcceptMail: s2b(entry.GetAttributeValue("acceptMail")),
...@@ -385,6 +391,7 @@ func (h *webdavResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Reso ...@@ -385,6 +391,7 @@ func (h *webdavResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Reso
if err != nil { if err != nil {
return nil, err return nil, err
} }
uid, _ := strconv.Atoi(entry.GetAttributeValue(uidNumberLDAPAttr))
return &accountserver.Resource{ return &accountserver.Resource{
ID: accountserver.NewResourceID( ID: accountserver.NewResourceID(
accountserver.ResourceTypeDAV, accountserver.ResourceTypeDAV,
...@@ -394,6 +401,7 @@ func (h *webdavResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Reso ...@@ -394,6 +401,7 @@ func (h *webdavResourceHandler) FromLDAP(entry *ldap.Entry) (*accountserver.Reso
Name: name, Name: name,
DAV: &accountserver.WebDAV{ DAV: &accountserver.WebDAV{
Homedir: entry.GetAttributeValue("homeDirectory"), Homedir: entry.GetAttributeValue("homeDirectory"),
UID: uid,
}, },
}, nil }, 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