Example #1
0
File: sync.go Project: richm/origin
// CreateErrorHandler creates an error handler for the LDAP sync job
func (o *SyncOptions) CreateErrorHandler() syncerror.Handler {
	components := []syncerror.Handler{}
	if o.Config.RFC2307Config != nil {
		if o.Config.RFC2307Config.TolerateMemberOutOfScopeErrors {
			components = append(components, syncerror.NewMemberLookupOutOfBoundsSuppressor(o.Stderr))
		}
		if o.Config.RFC2307Config.TolerateMemberNotFoundErrors {
			components = append(components, syncerror.NewMemberLookupMemberNotFoundSuppressor(o.Stderr))
		}
	}

	return syncerror.NewCompoundHandler(components...)
}
Example #2
0
func newTestLDAPInterface(client ldap.Client) *LDAPInterface {
	// below are common test implementations of LDAPInterface fields
	groupQuery := ldaputil.LDAPQueryOnAttribute{
		LDAPQuery: ldaputil.LDAPQuery{
			BaseDN:       "ou=groups,dc=example,dc=com",
			Scope:        ldaputil.ScopeWholeSubtree,
			DerefAliases: ldaputil.DerefAliasesAlways,
			TimeLimit:    0,
			Filter:       "objectClass=groupOfNames",
		},
		QueryAttribute: "dn",
	}
	groupNameAttributes := []string{"cn"}
	groupMembershipAttributes := []string{"member"}
	userQuery := ldaputil.LDAPQueryOnAttribute{
		LDAPQuery: ldaputil.LDAPQuery{
			BaseDN:       "ou=users,dc=example,dc=com",
			Scope:        ldaputil.ScopeWholeSubtree,
			DerefAliases: ldaputil.DerefAliasesAlways,
			TimeLimit:    0,
			Filter:       "objectClass=inetOrgPerson",
		},
		QueryAttribute: "dn",
	}
	userNameAttributes := []string{"cn"}

	errorHandler := syncerror.NewCompoundHandler(
		syncerror.NewMemberLookupOutOfBoundsSuppressor(ioutil.Discard),
		syncerror.NewMemberLookupMemberNotFoundSuppressor(ioutil.Discard),
	)

	return NewLDAPInterface(testclient.NewConfig(client),
		groupQuery,
		groupNameAttributes,
		groupMembershipAttributes,
		userQuery,
		userNameAttributes,
		errorHandler)
}