ldap

package
v1.5.17 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

LDAP manager

func NewManager

func NewManager(opt ...Opt) (*Manager, error)

func (*Manager) Bind

func (manager *Manager) Bind(ctx context.Context, dn, password string) (*schema.Object, error)

Bind a user to check if they are authenticated, returns httpresponse.ErrNotAuthorized if the credentials are invalid

func (*Manager) ChangePassword

func (manager *Manager) ChangePassword(ctx context.Context, dn, old string, new *string) (*schema.Object, error)

Change a password for a user. If the new password is empty, then the password is reset to a new random password and returned. The old password is required for the change if the ldap connection is not bound to the admin user.

func (*Manager) Connect

func (manager *Manager) Connect() error

Connect to the LDAP server, or ping the server if already connected

func (*Manager) Create

func (manager *Manager) Create(ctx context.Context, dn string, attr url.Values) (*schema.Object, error)

Create an object

func (*Manager) CreateGroup added in v1.5.13

func (manager *Manager) CreateGroup(ctx context.Context, user string, attrs url.Values) (*schema.Object, error)

Create a group

func (*Manager) CreateUser added in v1.5.13

func (manager *Manager) CreateUser(ctx context.Context, user string, attrs url.Values) (*schema.Object, error)

Create a user

func (*Manager) Delete

func (manager *Manager) Delete(ctx context.Context, dn string) (*schema.Object, error)

Delete an object by DN

func (*Manager) DeleteGroup added in v1.5.13

func (manager *Manager) DeleteGroup(ctx context.Context, group string) (*schema.Object, error)

Delete a group

func (*Manager) DeleteUser added in v1.5.13

func (manager *Manager) DeleteUser(ctx context.Context, user string) (*schema.Object, error)

Delete a user

func (*Manager) Disconnect

func (ldap *Manager) Disconnect() error

Disconnect from the LDAP server

func (*Manager) Get

func (manager *Manager) Get(ctx context.Context, dn string) (*schema.Object, error)

Get an object by DN

func (*Manager) GetGroup added in v1.5.13

func (manager *Manager) GetGroup(ctx context.Context, group string) (*schema.Object, error)

Get a group

func (*Manager) GetUser added in v1.5.13

func (manager *Manager) GetUser(ctx context.Context, user string) (*schema.Object, error)

Get a user

func (*Manager) Host

func (ldap *Manager) Host() string

Return the host for the LDAP connection

func (*Manager) List

func (manager *Manager) List(ctx context.Context, request schema.ObjectListRequest) (*schema.ObjectList, error)

Return the objects as a list

func (*Manager) ListAttributeTypes added in v1.5.13

func (manager *Manager) ListAttributeTypes(ctx context.Context) ([]*schema.AttributeType, error)

Returns attribute types

func (*Manager) ListGroups added in v1.5.13

func (manager *Manager) ListGroups(ctx context.Context, request schema.ObjectListRequest) (*schema.ObjectList, error)

Return all groups

func (*Manager) ListObjectClasses added in v1.5.13

func (manager *Manager) ListObjectClasses(ctx context.Context) ([]*schema.ObjectClass, error)

Returns object classes

func (*Manager) ListUsers added in v1.5.13

func (manager *Manager) ListUsers(ctx context.Context, request schema.ObjectListRequest) (*schema.ObjectList, error)

Return all users

func (*Manager) Port

func (ldap *Manager) Port() int

Return the port for the LDAP connection

func (*Manager) Run

func (manager *Manager) Run(ctx context.Context) error

func (*Manager) Update

func (manager *Manager) Update(ctx context.Context, dn string, attr url.Values) (*schema.Object, error)

Update attributes for an object. It will replace the attributes where the values is not empty, and delete the attributes where the values is empty. The object is returned after the update.

func (*Manager) User

func (ldap *Manager) User() string

Return the user for the LDAP connection

func (*Manager) WhoAmI

func (manager *Manager) WhoAmI() (string, error)

Return the user who is currently authenticated

type Opt

type Opt func(*opt) error

Opt represents a function that modifies the options

func WithBaseDN

func WithBaseDN(v string) Opt

func WithGroupSchema added in v1.5.13

func WithGroupSchema(dn, field string, classes ...string) Opt

func WithPassword

func WithPassword(v string) Opt

func WithSkipVerify

func WithSkipVerify() Opt

func WithUrl

func WithUrl(v string) Opt

func WithUser

func WithUser(v string) Opt

func WithUserSchema added in v1.5.13

func WithUserSchema(dn, field string, classes ...string) Opt

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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