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) DeleteGroupMembers(groupId string, membersIds ...string) (int, 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) Reconnect(ctx context.Context, tickerDuration time.Duration, maxAttempts int) 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) DeleteGroupMembers ¶
Deletes provided accounts IDs from provided group members. Returns number of deleted from group members.
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 ¶ added in v0.4.0
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 ¶ added in v0.4.0
func (args GetGroupArgs) Validate() error
type GetUserArgs ¶ added in v0.4.0
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 ¶ added in v0.4.0
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"` }
type Logger ¶ added in v0.2.0
type Logger interface { Debug(args ...interface{}) Debugf(template string, args ...interface{}) }
Client logger interface.
type Option ¶
type Option func(*Client)
func WithLogger ¶ added in v0.2.0
Specifies custom logger for client.
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"` }