ldap

package
v0.10.14 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUser

func AddUser(username, firstName, lastName, email, password string, attributes map[string][]string) error

AddUser adds a new user to the LDAP directory

func AddUserToGroup

func AddUserToGroup(username, groupName string) error

AddUserToGroup adds a user to a group

func Authenticate

func Authenticate(username, password string) (bool, error)

Authenticate authenticates a user with the given username and password

func Close

func Close()

Close closes the global LDAP connection.

func Conn

func Conn() *ldap.Conn

Conn returns the global LDAP connection. It returns nil if the connection is not initialized.

func DeleteUser

func DeleteUser(username string) error

DeleteUser deletes a user from the LDAP directory

func GetGroup

func GetGroup(groupName string, attributes []string) (*ldap.Entry, error)

GetGroup returns a group entry for a given group name

func GetGroupMembers

func GetGroupMembers(groupName string) ([]string, error)

GetGroupMembers returns all members of a given group

func GetUser

func GetUser(username string, attributes []string) (*ldap.Entry, error)

GetUser returns a user entry for a given username

func GetUserGroups

func GetUserGroups(username string) ([]string, error)

GetUserGroups returns all groups for a given username

func Init

func Init() (err error)

Init initializes the global LDAP connection. It reads LDAP configuration from config.App.Ldap. If LDAP is not enabled, it returns nil. The function is thread-safe and ensures the connection is initialized only once.

func ModifyUser

func ModifyUser(username string, changes map[string][]string) error

ModifyUser modifies an existing user in the LDAP directory

func New

func New(cfg config.Ldap) (*ldap.Conn, error)

New returns a new LDAP connection with given configuration. It's the caller's responsibility to close the connection, caller should always call Close() when it's no longer needed.

func RemoveUserFromGroup

func RemoveUserFromGroup(username, groupName string) error

RemoveUserFromGroup removes a user from a group

func Search(baseDN, filter string, attributes []string, scope int) ([]*ldap.Entry, error)

Search performs an LDAP search with the given parameters

func SearchWithContext

func SearchWithContext(ctx context.Context, baseDN, filter string, attributes []string, scope int) ([]*ldap.Entry, error)

SearchWithContext performs an LDAP search with context for timeout control

Types

This section is empty.

Jump to

Keyboard shortcuts

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