Documentation
¶
Overview ¶
Package adc provides basic client library for Active Directory.
Index ¶
- type BindAccount
- type Client
- func (cl *Client) AddGroupMembers(groupId string, membersIds ...string) (int, error)
- func (cl *Client) CheckAuthByDN(dn, password string) error
- func (cl *Client) Connect() error
- func (cl *Client) ConnectedStatus() bool
- func (cl *Client) CreateGroup(dn string, groupAttrs []ldap.Attribute) error
- func (cl *Client) CreateUser(dn string, userAttrs []ldap.Attribute) error
- func (cl *Client) DeleteGroup(dn string) error
- func (cl *Client) DeleteGroupMembers(groupId string, membersIds ...string) (int, error)
- func (cl *Client) DeleteUser(dn string) error
- func (cl *Client) Disconnect() error
- func (cl *Client) GetGroup(args GetGroupArgs) (*Group, error)
- func (cl *Client) GetUser(args GetUserArgs) (*User, error)
- func (cl *Client) ListGroups(args GetGroupArgs, pageSize int, filter string) (*[]Group, error)
- func (cl *Client) ListUsers(args GetUserArgs, pageSize int, filter string) (*[]User, error)
- func (cl *Client) Reconnect(ctx context.Context, tickerDuration time.Duration, maxAttempts int) error
- func (cl *Client) RenameGroup(dn string, rdn string) error
- func (cl *Client) SetPassword(dn string, newPassword string, mustChange bool) error
- func (cl *Client) UpdateUser(dn string, userAttrs []ldap.Attribute) error
- type Config
- type GetGroupArgs
- type GetUserArgs
- type Group
- type GroupMember
- type GroupsConfigs
- type Logger
- type Option
- type User
- type UserGroup
- type UsersConfigs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BindAccount ¶
Account attributes to authentificate in AD.
type Client ¶
type Client struct {
Config *Config
// contains filtered or unexported fields
}
Active Direcotry client.
func (*Client) AddGroupMembers ¶
Adds provided accounts IDs to provided group members. Returns number of addedd accounts.
func (*Client) CheckAuthByDN ¶
Tries to authorise in AcitveDirecotry by provided DN and password and return error if failed. Use this method to check if user can be authenticated in AD.
func (*Client) ConnectedStatus ¶ added in v0.0.4
func (*Client) CreateGroup ¶
func (*Client) CreateUser ¶
func (*Client) DeleteGroup ¶
func (*Client) DeleteGroupMembers ¶
Deletes provided accounts IDs from provided group members. Returns number of deleted from group members.
func (*Client) DeleteUser ¶
func (*Client) ListGroups ¶ added in v0.0.3
func (*Client) Reconnect ¶
func (cl *Client) Reconnect(ctx context.Context, tickerDuration time.Duration, maxAttempts int) error
Checks connections to AD and tries to reconnect if the connection is lost.
func (*Client) RenameGroup ¶ added in v0.0.9
func (*Client) SetPassword ¶ added in v0.0.5
type Config ¶
type Config struct {
// LDAP server URL. Examle 'ldaps://cl.local:636'
URL string `json:"url"`
// Use insecure SSL connection.
InsecureTLS bool `json:"insecure_tls"`
// Time limit for requests.
Timeout time.Duration
// Base OU for search requests.
SearchBase string `json:"search_base"`
// Bind account info.
Bind *BindAccount `json:"bind"`
// Requests filters vars.
Users *UsersConfigs `json:"users"`
// Requests filters vars.
Groups *GroupsConfigs `json:"groups"`
}
func (*Config) AppendGroupsAttributes ¶
Appends attributes to params in client config file.
func (*Config) AppendUsesAttributes ¶
Appends attributes to params in client config file.
type GetGroupArgs ¶
type GetGroupArgs struct {
// Group ID to search.
Id string `json:"id"`
// Optional group DN. Overwrites ID if provided in request.
Dn string `json:"dn"`
// Optional LDAP filter to search entry. Warning! provided Filter arg overwrites Id and Dn args usage.
Filter string `json:"filter"`
// Optional group attributes to overwrite attributes in client config.
Attributes []string `json:"attributes"`
// Skip search of group members data. Can improve request time.
SkipMembersSearch bool `json:"skip_members_search"`
}
func (GetGroupArgs) Validate ¶
func (args GetGroupArgs) Validate() error
type GetUserArgs ¶
type GetUserArgs struct {
// User ID to search.
Id string `json:"id"`
// Optional User DN. Overwrites ID if provided in request.
Dn string `json:"dn"`
// Optional LDAP filter to search entry. Warning! provided Filter arg overwrites Id and Dn args usage.
Filter string `json:"filter"`
// Optional user attributes to overwrite attributes in client config.
Attributes []string `json:"attributes"`
// Skip search of user groups data. Can improve request time.
SkipGroupsSearch bool `json:"skip_groups_search"`
}
func (GetUserArgs) Validate ¶
func (args GetUserArgs) Validate() error
type Group ¶
type Group struct {
DN string `json:"dn"`
Id string `json:"id"`
Attributes map[string]interface{} `json:"attributes"`
Members []GroupMember `json:"members"`
}
Active Direcotry group.
func (*Group) GetStringAttribute ¶
Returns string attribute by attribute name. Returns empty string if attribute not exists or it can't be covnerted to string.
type GroupMember ¶
Active Direcotry member info.
type GroupsConfigs ¶
type GroupsConfigs struct {
// The ID attribute name for group.
IdAttribute string `json:"id_attribute"`
// Group attributes for fetch from AD.
Attributes []string `json:"attributes"`
// Base OU to search groups requests. Sets to Config.SearchBase if not provided.
SearchBase string `json:"search_base"`
// LDAP filter to get group by ID.
FilterById string `json:"filter_by_id"`
// LDAP filter to get group by DN.
FilterByDn string `json:"filter_by_dn"`
// LDAP filter to get group members.
FilterMembersByDn string `json:"filter_members_by_dn"`
// Filter by group
FilterByGroup string `json:"filter_by_group"`
}
type Logger ¶
type Logger interface {
Debug(args ...interface{})
Debugf(template string, args ...interface{})
}
Client logger interface.
type User ¶
type User struct {
DN string `json:"dn"`
Id string `json:"id"`
Attributes map[string]interface{} `json:"attributes"`
Groups []UserGroup `json:"groups"`
}
Active Direcotry user.
func (*User) GetStringAttribute ¶
Returns string attribute by attribute name. Returns empty string if attribute not exists or it can't be covnerted to string.
func (*User) IsGroupMember ¶
type UsersConfigs ¶
type UsersConfigs struct {
// The ID attribute name for group.
IdAttribute string `json:"id_attribute"`
// User attributes for fetch from AD.
Attributes []string `json:"attributes"`
// Base OU to search users requests. Sets to Config.SearchBase if not provided.
SearchBase string `json:"search_base"`
// LDAP filter to get user by ID.
FilterById string `json:"filter_by_id"`
// LDAP filter to get user by DN.
FilterByDn string `json:"filter_by_dn"`
// LDAP filter to get user groups membership.
FilterGroupsByDn string `json:"filter_groups_by_dn"`
// Filter by person
FilterByPerson string `json:"filter_by_person"`
}