ldap

package module
v0.0.0-...-873b8e7 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 6 Imported by: 0

README

Simple LDAP Go

This package has been extracted from netresearch/raybeam and is for providing a simple API around go-ldap/ldap/v3.

License

This package is licensed under the MIT License. See the included LICENSE file for details.

Contributing

Feel free to contribute by creating a Pull Request!

This project uses Conventional Commits for commit messages and the default gofmt formatting rules.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound             = errors.New("user not found")
	ErrSAMAccountNameDuplicated = errors.New("sAMAccountName is not unique")
)
View Source
var (
	ErrActiveDirectoryMustBeLDAPS = errors.New("ActiveDirectory servers must be connected to via LDAPS to change passwords")
)
View Source
var ErrComputerNotFound = errors.New("computer not found")
View Source
var ErrDNDuplicated = errors.New("DN is not unique")
View Source
var ErrGroupNotFound = errors.New("group not found")

Functions

This section is empty.

Types

type Computer

type Computer struct {
	Object
	SAMAccountName string
	Enabled        bool
	OS             string
	OSVersion      string
	// Groups is a list of CNs
	Groups []string
}

type Config

type Config struct {
	Server string
	BaseDN string

	IsActiveDirectory bool
}

type Group

type Group struct {
	Object
	// Members is a list of DNs
	Members []string
}

type LDAP

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

func New

func New(config Config, user, password string) (*LDAP, error)

func (*LDAP) AddUserToGroup

func (l *LDAP) AddUserToGroup(dn, groupDN string) error

func (*LDAP) ChangePasswordForSAMAccountName

func (l *LDAP) ChangePasswordForSAMAccountName(sAMAccountName, oldPassword, newPassword string) (err error)

func (*LDAP) CheckPasswordForDN

func (l *LDAP) CheckPasswordForDN(dn, password string) (*User, error)

func (*LDAP) CheckPasswordForSAMAccountName

func (l *LDAP) CheckPasswordForSAMAccountName(sAMAccountName, password string) (*User, error)

func (*LDAP) FindComputerByDN

func (l *LDAP) FindComputerByDN(dn string) (computer *Computer, err error)

func (*LDAP) FindComputerBySAMAccountName

func (l *LDAP) FindComputerBySAMAccountName(sAMAccountName string) (computer *Computer, err error)

func (*LDAP) FindComputers

func (l *LDAP) FindComputers() (computers []Computer, err error)

func (*LDAP) FindGroupByDN

func (l *LDAP) FindGroupByDN(dn string) (group *Group, err error)

func (*LDAP) FindGroups

func (l *LDAP) FindGroups() (groups []Group, err error)

func (*LDAP) FindUserByDN

func (l *LDAP) FindUserByDN(dn string) (user *User, err error)

func (*LDAP) FindUserBySAMAccountName

func (l *LDAP) FindUserBySAMAccountName(sAMAccountName string) (user *User, err error)

func (*LDAP) FindUsers

func (l *LDAP) FindUsers() (users []User, err error)

func (*LDAP) RemoveUserFromGroup

func (l *LDAP) RemoveUserFromGroup(dn, groupDN string) error

func (*LDAP) WithCredentials

func (l *LDAP) WithCredentials(dn, password string) (*LDAP, error)

type Object

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

func (Object) CN

func (o Object) CN() string

func (Object) DN

func (o Object) DN() string

type User

type User struct {
	Object
	SAMAccountName string
	Enabled        bool
	// Groups is a list of CNs
	Groups []string
}

Jump to

Keyboard shortcuts

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