ldap

package
v0.0.0-...-c079afc Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExist = errors.New("Already exist an entry with this uid/cn")
View Source
var ErrNotFound = errors.New("Can't find the record in the ldap")

Functions

This section is empty.

Types

type Group

type Group struct {
	DN          string
	Name        string
	GID         int
	Description string
	Members     []string
	OpenPGPkey  *OpenPGPkey
}

Group has the ldap data of the group

type Ldap

type Ldap struct {
	Addr       string
	Domain     string
	Pass       string
	HomePath   string
	DC         string
	MailDomain string
	RO         bool
}

Ldap configuration

func (Ldap) AddGroup

func (l Ldap) AddGroup(group string, description string) error

AddGroup adds the group to ldap

func (*Ldap) AddUser

func (l *Ldap) AddUser(user string, pass string, gid int) error

AddUser to the ldap

func (Ldap) AddUserGroup

func (l Ldap) AddUserGroup(user string, group string) error

AddUserGroup add user into the group members

func (Ldap) ChangeGroupOpenPGPkey

func (l Ldap) ChangeGroupOpenPGPkey(group string, fingerprint string, expiry time.Time, key []byte, wkdHash string) error

ChangeGroupOpenPGPkey updates or sets a new OpenPGPkey for the group

func (Ldap) ChangeLocked

func (l Ldap) ChangeLocked(user string, locked Locked) error

ChangeLocked for the user

func (Ldap) ChangePass

func (l Ldap) ChangePass(user string, oldpass string, newpass string) error

ChangePass changes logged in user's password

func (Ldap) ChangePassAdmin

func (l Ldap) ChangePassAdmin(user string, pass string) error

ChangePassAdmin changes user's password as admin (without knowing the old password)

func (Ldap) ChangeRole

func (l Ldap) ChangeRole(user string, role Role) error

ChangeRole for the user

func (Ldap) ChangeShell

func (l Ldap) ChangeShell(user, shell string) error

ChangeShell for the user

func (Ldap) ChangeUserOpenPGPkey

func (l Ldap) ChangeUserOpenPGPkey(user string, fingerprint string, expiry time.Time, key []byte, wkdHash string) error

ChangeUserOpenPGPkey updates or sets a new OpenPGPkey for the user

func (Ldap) DelGroup

func (l Ldap) DelGroup(group string) error

DelGroup removes the group in ldap

func (Ldap) DelUser

func (l Ldap) DelUser(user string) error

DelUser removes the user from ldap

func (Ldap) DelUserGroup

func (l Ldap) DelUserGroup(user string, group string) error

DelUserGroup removes the user from the group members

func (Ldap) DeleteOpenPGPkey

func (l Ldap) DeleteOpenPGPkey(dn string) error

func (Ldap) EmptyGroup

func (l Ldap) EmptyGroup(group string) error

EmptyGroup removes all the members from the group

func (Ldap) GetGID

func (l Ldap) GetGID(gid int) (Group, error)

GetGID returns the group matching the gid

func (Ldap) GetGroup

func (l Ldap) GetGroup(name string) (Group, error)

GetGroup returns the group matching the name

func (Ldap) GetUser

func (l Ldap) GetUser(name string) (User, error)

GetUser returns the user data

func (Ldap) GetUserRole

func (l Ldap) GetUserRole(user string) Role

GetUserRole returns the role of the user

func (Ldap) InGroup

func (l Ldap) InGroup(user string, group string) bool

InGroup checks if user is part of group

func (*Ldap) Init

func (l *Ldap) Init() error

Init the Ldap connection

func (Ldap) IsUserPassUptodate

func (l Ldap) IsUserPassUptodate(user string) bool

IsUserPassUptodate will be true if the password for that user in ldap is using the latest crypto

func (Ldap) ListGroups

func (l Ldap) ListGroups() ([]Group, error)

ListGroups returns all groups in ldap with members

func (Ldap) ListUsers

func (l Ldap) ListUsers() ([]User, error)

ListUsers returns a list of all users in the ldap

func (Ldap) UpdateGroupDescription

func (l Ldap) UpdateGroupDescription(group string, description string) error

UpdateGroupDescription set a new description for the group

func (Ldap) UserGroups

func (l Ldap) UserGroups(user string) ([]Group, error)

UserGroups returns a list of groups the user is member of

func (Ldap) ValidateUser

func (l Ldap) ValidateUser(user string, pass string) (User, error)

ValidateUser in the ldap

type Locked

type Locked int
const (
	Unlocked Locked = iota
	Blocked
	Deleted
	Unknown
)

func LockedFromString

func LockedFromString(s string) Locked

func (Locked) String

func (r Locked) String() string

type OpenPGPkey

type OpenPGPkey struct {
	Fingerprint string
	Expiry      time.Time
	Key         []byte
	WkdHash     string
}

type Role

type Role int
const (
	Undefined Role = iota
	Amiga
	Sindominante
)

func RoleFromString

func RoleFromString(s string) Role

func (Role) String

func (r Role) String() string

type User

type User struct {
	DN         string
	Name       string
	Shell      string
	Home       string
	Mail       string
	UID        int
	GID        int
	Role       Role
	Locked     Locked
	OpenPGPkey *OpenPGPkey
	LastLogin  time.Time
}

User has the ldap data of the user

Jump to

Keyboard shortcuts

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