forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ad.go
54 lines (43 loc) · 1.58 KB
/
ad.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package cli
import (
"github.com/openshift/origin/pkg/auth/ldaputil"
"github.com/openshift/origin/pkg/auth/ldaputil/ldapclient"
"github.com/openshift/origin/pkg/cmd/admin/groups/sync"
"github.com/openshift/origin/pkg/cmd/admin/groups/sync/ad"
"github.com/openshift/origin/pkg/cmd/admin/groups/sync/interfaces"
"github.com/openshift/origin/pkg/cmd/server/api"
)
var _ SyncBuilder = &ADBuilder{}
var _ PruneBuilder = &ADBuilder{}
type ADBuilder struct {
ClientConfig ldapclient.Config
Config *api.ActiveDirectoryConfig
adLDAPInterface *ad.ADLDAPInterface
}
func (b *ADBuilder) GetGroupLister() (interfaces.LDAPGroupLister, error) {
return b.getADLDAPInterface()
}
func (b *ADBuilder) GetGroupNameMapper() (interfaces.LDAPGroupNameMapper, error) {
return &syncgroups.DNLDAPGroupNameMapper{}, nil
}
func (b *ADBuilder) GetUserNameMapper() (interfaces.LDAPUserNameMapper, error) {
return syncgroups.NewUserNameMapper(b.Config.UserNameAttributes), nil
}
func (b *ADBuilder) GetGroupMemberExtractor() (interfaces.LDAPMemberExtractor, error) {
return b.getADLDAPInterface()
}
func (b *ADBuilder) getADLDAPInterface() (*ad.ADLDAPInterface, error) {
if b.adLDAPInterface != nil {
return b.adLDAPInterface, nil
}
userQuery, err := ldaputil.NewLDAPQuery(b.Config.AllUsersQuery)
if err != nil {
return nil, err
}
b.adLDAPInterface = ad.NewADLDAPInterface(b.ClientConfig,
userQuery, b.Config.GroupMembershipAttributes, b.Config.UserNameAttributes)
return b.adLDAPInterface, nil
}
func (b *ADBuilder) GetGroupDetector() (interfaces.LDAPGroupDetector, error) {
return b.getADLDAPInterface()
}