ldap

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 20 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 New

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

func (*Manager) AddGroupUsers

func (manager *Manager) AddGroupUsers(ctx context.Context, groupcn string, usercn ...string) (*schema.Object, error)

Add users to a group, and return the updated group. Membership changes are applied with a single LDAP modify request on the group entry.

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, *string, 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 may be omitted when the directory permits administrative password resets.

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

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

Create a group with optional additional attributes. If posixGroup is one of the configured group object classes and no gidNumber is supplied, the next available GID is allocated atomically from the cn=lastgid device entry.

func (*Manager) CreateUser

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

Create a user. When allocateGID is true and gidNumber is not supplied for a posixAccount entry, gidNumber is set to the effective uidNumber.

func (*Manager) Delete

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

Delete an object by DN

func (*Manager) DeleteGroup

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

Delete a group by cn

func (*Manager) DeleteUser

func (manager *Manager) DeleteUser(ctx context.Context, cn 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

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

Get a group by cn

func (*Manager) GetUser

func (manager *Manager) GetUser(ctx context.Context, cn 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

func (manager *Manager) ListAttributeTypes(ctx context.Context, req schema.AttributeTypeListRequest) (*schema.AttributeTypeListResponse, error)

Returns attribute types

func (*Manager) ListGroups

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

Return all groups

func (*Manager) ListObjectClasses

func (manager *Manager) ListObjectClasses(ctx context.Context, req schema.ObjectClassListRequest) (*schema.ObjectClassListResponse, error)

Returns object classes

func (*Manager) ListUsers

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

Return all users

func (*Manager) Port

func (ldap *Manager) Port() uint

Return the port for the LDAP connection

func (*Manager) RemoveGroupUsers

func (manager *Manager) RemoveGroupUsers(ctx context.Context, groupcn string, usercn ...string) (*schema.Object, error)

Remove users from a group, and return the updated group. Membership changes are applied with a single LDAP modify request on the group entry.

func (*Manager) Run

func (manager *Manager) Run(ctx context.Context, logger *slog.Logger) 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. If the request changes an RDN attribute, the entry is renamed first and then modified. The object is returned after the update.

func (*Manager) UpdateGroup

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

Update attributes for a group. It will replace the attributes where the values are not empty, and delete the attributes where the values are empty. If the request changes the naming attribute, the entry is renamed first and then modified. The updated group is returned.

func (*Manager) UpdateUser

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

Update attributes for a user. It will replace the attributes where the values are not empty, and delete the attributes where the values are empty. If the request changes the naming attribute, the entry is renamed first and then modified. The updated user is returned.

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 WithGroupDN

func WithGroupDN(dn 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 WithUserDN

func WithUserDN(dn string, classes ...string) Opt

Jump to

Keyboard shortcuts

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