ldap

package
v2.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	URI          string
	BindDN       string
	BindPassword string
	TLSConfig    *tls.Config
}

Config holds the basic configuration of the LDAP Connection

type ConnWithReconnect

type ConnWithReconnect struct {
	// contains filtered or unexported fields
}

ConnWithReconnect maintains an LDAP Connection that automatically reconnects after network errors

func NewLDAPWithReconnect

func NewLDAPWithReconnect(config Config) *ConnWithReconnect

NewLDAPWithReconnect Returns a new ConnWithReconnect initialized from config

func (*ConnWithReconnect) Add

func (c *ConnWithReconnect) Add(a *ldap.AddRequest) error

Add implements the ldap.Client interface

func (*ConnWithReconnect) Bind

func (c *ConnWithReconnect) Bind(username, password string) error

Bind implements the ldap.Client interface

func (*ConnWithReconnect) Close

func (c *ConnWithReconnect) Close() (err error)

Close implements the ldap.Client interface

func (*ConnWithReconnect) Compare

func (c *ConnWithReconnect) Compare(dn, attribute, value string) (bool, error)

Compare implements the ldap.Client interface

func (*ConnWithReconnect) Del

func (c *ConnWithReconnect) Del(d *ldap.DelRequest) error

Del implements the ldap.Client interface

func (*ConnWithReconnect) DirSync added in v2.15.0

func (c *ConnWithReconnect) DirSync(searchRequest *ldap.SearchRequest, flags, maxAttrCount int64, cookie []byte) (*ldap.SearchResult, error)

DirSync implements the ldap.Client interface

func (*ConnWithReconnect) DirSyncAsync added in v2.17.0

func (c *ConnWithReconnect) DirSyncAsync(ctx context.Context, searchRequest *ldap.SearchRequest, bufferSize int, flags, maxAttrCount int64, cookie []byte) ldap.Response

DirSyncAsync implements the ldap.Client interface

func (*ConnWithReconnect) ExternalBind

func (c *ConnWithReconnect) ExternalBind() error

ExternalBind implements the ldap.Client interface

func (*ConnWithReconnect) GetLastError added in v2.15.0

func (c *ConnWithReconnect) GetLastError() error

func (*ConnWithReconnect) IsClosing

func (c *ConnWithReconnect) IsClosing() bool

IsClosing implements the ldap.Client interface

func (*ConnWithReconnect) Modify

func (c *ConnWithReconnect) Modify(m *ldap.ModifyRequest) error

Modify implements the ldap.Client interface

func (*ConnWithReconnect) ModifyDN

func (c *ConnWithReconnect) ModifyDN(m *ldap.ModifyDNRequest) error

ModifyDN implements the ldap.Client interface

func (*ConnWithReconnect) ModifyWithResult

func (c *ConnWithReconnect) ModifyWithResult(m *ldap.ModifyRequest) (*ldap.ModifyResult, error)

ModifyWithResult implements the ldap.Client interface

func (*ConnWithReconnect) NTLMUnauthenticatedBind added in v2.7.3

func (c *ConnWithReconnect) NTLMUnauthenticatedBind(domain, username string) error

NTLMUnauthenticatedBind implements the ldap.Client interface

func (*ConnWithReconnect) PasswordModify

func (c *ConnWithReconnect) PasswordModify(*ldap.PasswordModifyRequest) (*ldap.PasswordModifyResult, error)

PasswordModify implements the ldap.Client interface

func (*ConnWithReconnect) Search

func (c *ConnWithReconnect) Search(sr *ldap.SearchRequest) (*ldap.SearchResult, error)

Search implements the ldap.Client interface

func (*ConnWithReconnect) SearchAsync added in v2.17.0

func (c *ConnWithReconnect) SearchAsync(ctx context.Context, searchRequest *ldap.SearchRequest, bufferSize int) ldap.Response

SearchAsync implements the ldap.Client interface

func (*ConnWithReconnect) SearchWithPaging

func (c *ConnWithReconnect) SearchWithPaging(searchRequest *ldap.SearchRequest, pagingSize uint32) (*ldap.SearchResult, error)

SearchWithPaging implements the ldap.Client interface

func (*ConnWithReconnect) SetLogger

func (c *ConnWithReconnect) SetLogger(logger *zerolog.Logger)

SetLogger sets the logger for the current instance

func (*ConnWithReconnect) SetTimeout

func (c *ConnWithReconnect) SetTimeout(time.Duration)

SetTimeout implements the ldap.Client interface

func (*ConnWithReconnect) SimpleBind

func (c *ConnWithReconnect) SimpleBind(*ldap.SimpleBindRequest) (*ldap.SimpleBindResult, error)

SimpleBind implements the ldap.Client interface

func (*ConnWithReconnect) Start

func (c *ConnWithReconnect) Start()

Start implements the ldap.Client interface

func (*ConnWithReconnect) StartTLS

func (c *ConnWithReconnect) StartTLS(*tls.Config) error

StartTLS implements the ldap.Client interface

func (*ConnWithReconnect) Syncrepl added in v2.17.0

func (c *ConnWithReconnect) Syncrepl(ctx context.Context, searchRequest *ldap.SearchRequest, bufferSize int, mode ldap.ControlSyncRequestMode, cookie []byte, reloadHint bool) ldap.Response

Syncrepl implements the ldap.Client interface

func (*ConnWithReconnect) TLSConnectionState added in v2.7.3

func (c *ConnWithReconnect) TLSConnectionState() (tls.ConnectionState, bool)

TLSConnectionState implements the ldap.Client interface

func (*ConnWithReconnect) UnauthenticatedBind

func (c *ConnWithReconnect) UnauthenticatedBind(username string) error

UnauthenticatedBind implements the ldap.Client interface

func (*ConnWithReconnect) Unbind added in v2.7.3

func (c *ConnWithReconnect) Unbind() error

Unbind implements the ldap.Client interface

type Identity

type Identity struct {
	User  userConfig  `mapstructure:",squash"`
	Group groupConfig `mapstructure:",squash"`
}

Identity provides methods to query users and groups from an LDAP server

func New

func New() Identity

New initializes the default config

func (*Identity) GetLDAPGroupByAttribute

func (i *Identity) GetLDAPGroupByAttribute(log *zerolog.Logger, lc ldap.Client, attribute, value string) (*ldap.Entry, error)

GetLDAPGroupByAttribute looks up a single group by attribute (can be "mail", "gid_number", "display_name", "group_name", "group_id"). Returns the corresponding ldap.Entry

func (*Identity) GetLDAPGroupByFilter

func (i *Identity) GetLDAPGroupByFilter(log *zerolog.Logger, lc ldap.Client, filter string) (*ldap.Entry, error)

GetLDAPGroupByFilter looks up a single group by the supplied LDAP filter returns the corresponding ldap.Entry

func (*Identity) GetLDAPGroupByID

func (i *Identity) GetLDAPGroupByID(log *zerolog.Logger, lc ldap.Client, id string) (*ldap.Entry, error)

GetLDAPGroupByID looks up a group by the supplied Id. Returns the corresponding ldap.Entry

func (*Identity) GetLDAPGroupMembers

func (i *Identity) GetLDAPGroupMembers(log *zerolog.Logger, lc ldap.Client, group *ldap.Entry) ([]*ldap.Entry, error)

GetLDAPGroupMembers looks up all members of the supplied LDAP group entry and returns the corresponding LDAP user entries

func (*Identity) GetLDAPGroups

func (i *Identity) GetLDAPGroups(log *zerolog.Logger, lc ldap.Client, query string) ([]*ldap.Entry, error)

GetLDAPGroups searches for groups using a prefix-substring match on the group attributes. Returns a slice of matching ldap.Entries

func (*Identity) GetLDAPUserByAttribute

func (i *Identity) GetLDAPUserByAttribute(log *zerolog.Logger, lc ldap.Client, attribute, value string) (*ldap.Entry, error)

GetLDAPUserByAttribute looks up a single user by attribute (can be "mail", "uid", "gid", "username" or "userid"). Returns the corresponding ldap.Entry

func (*Identity) GetLDAPUserByDN

func (i *Identity) GetLDAPUserByDN(log *zerolog.Logger, lc ldap.Client, dn string) (*ldap.Entry, error)

GetLDAPUserByDN looks up a single user by the supplied LDAP DN returns the corresponding ldap.Entry

func (*Identity) GetLDAPUserByFilter

func (i *Identity) GetLDAPUserByFilter(log *zerolog.Logger, lc ldap.Client, filter string) (*ldap.Entry, error)

GetLDAPUserByFilter looks up a single user by the supplied LDAP filter returns the corresponding ldap.Entry

func (*Identity) GetLDAPUserByID

func (i *Identity) GetLDAPUserByID(log *zerolog.Logger, lc ldap.Client, id string) (*ldap.Entry, error)

GetLDAPUserByID looks up a user by the supplied Id. Returns the corresponding ldap.Entry

func (*Identity) GetLDAPUserGroups

func (i *Identity) GetLDAPUserGroups(log *zerolog.Logger, lc ldap.Client, userEntry *ldap.Entry) ([]string, error)

GetLDAPUserGroups looks up the group member ship of the supplied LDAP user entry. Returns a slice of strings with groupids

func (*Identity) GetLDAPUsers

func (i *Identity) GetLDAPUsers(log *zerolog.Logger, lc ldap.Client, query string) ([]*ldap.Entry, error)

GetLDAPUsers searches for users using a prefix-substring match on the user attributes. Returns a slice of matching ldap.Entries

func (*Identity) GetUserType added in v2.13.0

func (i *Identity) GetUserType(userEntry *ldap.Entry) identityUser.UserType

GetUserType is used to get the proper UserType from ldap entry string

func (*Identity) IsLDAPUserInDisabledGroup added in v2.13.0

func (i *Identity) IsLDAPUserInDisabledGroup(log *zerolog.Logger, lc ldap.Client, userEntry *ldap.Entry) bool

IsLDAPUserInDisabledGroup checkes if the user is in the disabled group.

func (*Identity) Setup

func (i *Identity) Setup() error

Setup initialzes some properties that can't be initialized from the mapstructure based config. Currently it just converts the LDAP search scope strings from the config to the integer constants expected by the ldap API

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL