ldap

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DEF_LDAP_TIMEOUT time.Duration = 20 * time.Second
)

Functions

func ExtractLdapGroupName

func ExtractLdapGroupName(userDn *string) []string

userDn = ldap-u1-cn userDn = cn=ldap-u1-cn,ou=users,dc=sdp-console,dc=cn return [groupName, groupDn]

func FetchLdapEntries

func FetchLdapEntries(fields *AuthingLdapFields, group bool) (result []*ldap.Entry, err error)

func FetchLdapEntriesByIdp

func FetchLdapEntriesByIdp(jsonStrFields string, group bool) (result []*ldap.Entry, err error)

func GetLDAPEntryName

func GetLDAPEntryName(entry *ldap.Entry) string

func NewLdapPool

func NewLdapPool(opts *LdapConnOptions) (ldappool.Pool, error)

初始化连接池

func SearchAllUserGroups

func SearchAllUserGroups(jsonStrFields string) ([]*ldap.Entry, error)

func TestLdapConn

func TestLdapConn(fields *AuthingLdapFields) error

func TestLdapConnByIdp

func TestLdapConnByIdp(jsonStrFields string) error

Types

type AuthingLdapFields

type AuthingLdapFields struct {
	Url                string `json:"url"`                //"ldaps://127.0.0.1:636",
	BindDN             string `json:"bindDN"`             //"cn=admin,dc=sdp-console,dc=com",
	BindCredentials    string `json:"bindCredentials"`    //"123456",
	BASE_DN            string `json:"BASE_DN"`            //"dc=sdp-console,dc=com",
	QueryCriteria      string `json:"queryCriteria"`      //"&(objectClass=organizationalPerson)(cn=%s)"
	GroupQueryCriteria string `json:"groupQueryCriteria"` //"&(objectClass=organizationalPerson)(cn=%s)"
}

type LdapAttributes

type LdapAttributes struct {
	// ldap字段
	Num         string `json:"employeeNumber"`     // 工号
	Sam         string `json:"sAMAccountName"`     // SAM账号
	Dn          string `json:"distinguishedName"`  // dn
	AccountCtl  string `json:"UserAccountControl"` // 用户账户控制
	Expire      string `json:"accountExpires"`     //  账户过期时间
	PwdLastSet  string `json:"pwdLastSet"`         //  用户下次登录必须修改密码
	WhenCreated string `json:"whenCreated"`        //  创建时间
	WhenChanged string `json:"whenChanged"`        //  修改时间
	DisplayName string `json:"displayName"`        //  真实姓名
	Sn          string `json:"sn"`                 //  姓
	Name        string `json:"name"`               // 姓名
	GivenName   string `json:"givenName"`          // 名
	Email       string `json:"mail"`               // 邮箱
	Phone       string `json:"mobile"`             // 移动电话
	Company     string `json:"company"`            // 公司
	Depart      string `json:"department"`         // 部门
	Title       string `json:"title"`              // 职务
}

type LdapConnOptions

type LdapConnOptions struct {
	ConnUrl       string        `json:"conn_url"`       // 连接地址
	SslEncryption bool          `json:"ssl_encryption"` // SSL加密方式
	Timeout       time.Duration `json:"timeout"`        // 超时设置
	BaseDn        string        `json:"base_dn"`        // 根目录
	AdminAccount  string        `json:"admin_account"`  // 用户名
	Password      string        `json:"password"`       // 密码
}

func NewLdapConnOptions

func NewLdapConnOptions() *LdapConnOptions

type LdapService

type LdapService struct {
	LdapConnOptions
	// contains filtered or unexported fields
}

func NewLdapService

func NewLdapService(opts *LdapConnOptions) *LdapService

func (*LdapService) CheckGetConn

func (s *LdapService) CheckGetConn() (*ldappool.PoolConn, error)

func (*LdapService) CheckUser

func (s *LdapService) CheckUser()

func (*LdapService) CloseAll

func (s *LdapService) CloseAll() error

func (*LdapService) CloseConn

func (s *LdapService) CloseConn() error

func (*LdapService) ClosePool

func (s *LdapService) ClosePool() error

func (*LdapService) FetchEntries

func (s *LdapService) FetchEntries(queryCriteria string) (result []*ldap.Entry, err error)

func (*LdapService) Init

func (s *LdapService) Init() error

func (*LdapService) InitAll

func (s *LdapService) InitAll() error

func (*LdapService) TryConn

func (s *LdapService) TryConn() error

Jump to

Keyboard shortcuts

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