2021-11-05 09:37:30 +00:00
|
|
|
package direct
|
2021-09-26 12:01:22 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/nmcclain/ldap"
|
|
|
|
"goauthentik.io/internal/constants"
|
2021-11-05 09:37:30 +00:00
|
|
|
"goauthentik.io/internal/outpost/ldap/search"
|
2021-09-26 12:01:22 +00:00
|
|
|
)
|
|
|
|
|
2021-11-05 09:37:30 +00:00
|
|
|
func (ds *DirectSearcher) SearchBase(req *search.Request, authz bool) (ldap.ServerSearchResult, error) {
|
2021-09-26 12:01:22 +00:00
|
|
|
dn := ""
|
|
|
|
if authz {
|
|
|
|
dn = req.SearchRequest.BaseDN
|
|
|
|
}
|
|
|
|
return ldap.ServerSearchResult{
|
|
|
|
Entries: []*ldap.Entry{
|
|
|
|
{
|
|
|
|
DN: dn,
|
|
|
|
Attributes: []*ldap.EntryAttribute{
|
|
|
|
{
|
|
|
|
Name: "distinguishedName",
|
2021-11-05 09:37:30 +00:00
|
|
|
Values: []string{ds.si.GetBaseDN()},
|
2021-09-26 12:01:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "objectClass",
|
|
|
|
Values: []string{"top", "domain"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "supportedLDAPVersion",
|
|
|
|
Values: []string{"3"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "namingContexts",
|
|
|
|
Values: []string{
|
2021-11-05 09:37:30 +00:00
|
|
|
ds.si.GetBaseDN(),
|
|
|
|
ds.si.GetBaseUserDN(),
|
|
|
|
ds.si.GetBaseGroupDN(),
|
2021-09-26 12:01:22 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "vendorName",
|
|
|
|
Values: []string{"goauthentik.io"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "vendorVersion",
|
|
|
|
Values: []string{fmt.Sprintf("authentik LDAP Outpost Version %s (build %s)", constants.VERSION, constants.BUILD())},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Referrals: []string{}, Controls: []ldap.Control{}, ResultCode: ldap.LDAPResultSuccess,
|
|
|
|
}, nil
|
|
|
|
}
|