ldapclient

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPwd string = "BGgsh*1050"

Functions

func Auth

func Auth(lc *TLdapClient, username, password string) (success bool, err error)

func HealthCheck

func HealthCheck(lc *TLdapClient) (success bool, err error)

func ParseTicks

func ParseTicks(ticks string) (time.Time, error)

ParseTicks parses dates represented as Active Directory LargeInts into times. Not all time fields are represented this way, so be sure to test that your particular time returns expected results. Some time fields represented as LargeInts include accountExpires, lastLogon, lastLogonTimestamp, and pwdLastSet. More: https://social.technet.microsoft.com/wiki/contents/articles/31135.active-directory-large-integer-attributes.aspx

func TicksToTime

func TicksToTime(ticks int64) time.Time

TicksToTime converts an ActiveDirectory time in ticks to a time. This algorithm is summarized as:

Many dates are saved in Active Directory as Large Integer values.
These attributes represent dates as the number of 100-nanosecond intervals since 12:00 AM January 1, 1601.
100-nanosecond intervals, equal to 0.0000001 seconds, are also called ticks.
Dates in Active Directory are always saved in Coordinated Universal Time, or UTC.
More: https://social.technet.microsoft.com/wiki/contents/articles/31135.active-directory-large-integer-attributes.aspx

If we directly follow the above algorithm we encounter time.Duration limits of 290 years and int overflow issues. Thus below, we carefully sidestep those.

Types

type TLdapClient

type TLdapClient struct {
	Addr       string   `json:"addr"`
	BaseDn     string   `json:"baseDn"`
	BindDn     string   `json:"bindDn`
	BindPass   string   `json:"bindPass"`
	AuthFilter string   `json:"authFilter"`
	Attributes []string `json:"attributes"`
	MailDomain string   `json:"mailDomain"`
	TLS        bool     `json:"tls"`
	StartTLS   bool     `json:"startTLS"`
	Conn       *ldap.Conn
}

func (*TLdapClient) AddGroupUser

func (lc *TLdapClient) AddGroupUser(path string, groupName, userDN string) error

func (*TLdapClient) Auth

func (lc *TLdapClient) Auth(username, password string) (success bool, err error)

func (*TLdapClient) Bind

func (lc *TLdapClient) Bind(username, password string) (success bool, err error)

func (*TLdapClient) ChangePassword

func (lc *TLdapClient) ChangePassword(path string, staff_code, new_password string) error

func (*TLdapClient) Close

func (lc *TLdapClient) Close()

func (*TLdapClient) Connect

func (lc *TLdapClient) Connect() (err error)

func (*TLdapClient) CreateGroup

func (lc *TLdapClient) CreateGroup(path string, groupName string) error

func (*TLdapClient) CreatePath

func (lc *TLdapClient) CreatePath(path string, pathName string) error

func (*TLdapClient) DelGroupUser

func (lc *TLdapClient) DelGroupUser(path string, groupName, userDN string) error

func (*TLdapClient) DeleteGroup

func (lc *TLdapClient) DeleteGroup(path string, group_name string) error

func (*TLdapClient) DeletePath

func (lc *TLdapClient) DeletePath(path string, path_name string) error

func (*TLdapClient) DeleteUser

func (lc *TLdapClient) DeleteUser(path string, staff_code string) error

func (*TLdapClient) DisableAccount

func (lc *TLdapClient) DisableAccount(staff_code string) error

func (*TLdapClient) EnableAccount

func (lc *TLdapClient) EnableAccount(staff_code string) error

func (*TLdapClient) GetSearchResult

func (lc *TLdapClient) GetSearchResult(entry *ldap.Entry) *TResultLdap

func (*TLdapClient) IsClosing

func (lc *TLdapClient) IsClosing() bool

func (*TLdapClient) Search

func (lc *TLdapClient) Search(SearchFilter string, scope int) (results []*TResultLdap, err error)

func (*TLdapClient) SearchBase

func (lc *TLdapClient) SearchBase(SearchFilter string) (results []*TResultLdap, err error)

func (*TLdapClient) SearchSubAll

func (lc *TLdapClient) SearchSubAll(SearchFilter string) (results []*TResultLdap, err error)

func (*TLdapClient) SearchSubOne

func (lc *TLdapClient) SearchSubOne(SearchFilter string) (results []*TResultLdap, err error)

func (*TLdapClient) SearchUser

func (lc *TLdapClient) SearchUser(username string) (user *TResultLdap, err error)

func (*TLdapClient) SetExternalEmailAddress

func (lc *TLdapClient) SetExternalEmailAddress(path, staff_code, mail, display_name string) error

type TLdapUser added in v1.1.1

type TLdapUser struct {
	StaffCode string `json:"code"`    //工号
	StaffName string `json:"name"`    //姓名
	Email     string `json:"mail"`    //邮箱
	Org       string `json:"org"`     //组织
	Dept      string `json:"dept"`    //部门
	Phone     string `json:"phone"`   //手机
	Company   string `json:"belong"`  //公司
	Station   string `json:"station"` //南京
}

func (*TLdapUser) String added in v1.1.1

func (Self *TLdapUser) String() string

type TResultLdap

type TResultLdap struct {
	DN    string              `json:"dn"`
	Attrs map[string][]string `json:"attributes"`
}
func Search(lc *TLdapClient, SearchFilter string) (results []*TResultLdap, err error)

func SearchUser

func SearchUser(lc *TLdapClient, username string) (user *TResultLdap, err error)

func (*TResultLdap) GetAttr

func (Self *TResultLdap) GetAttr(name string) string

func (*TResultLdap) GetAttrByInt

func (Self *TResultLdap) GetAttrByInt(name string) int

func (*TResultLdap) String

func (Self *TResultLdap) String() string

Jump to

Keyboard shortcuts

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