Documentation
¶
Index ¶
- Variables
- type Client
- type Config
- type LDAPConn
- func (l *LDAPConn) GetBaseUserDN() string
- func (l *LDAPConn) GetGroupDN() string
- func (l *LDAPConn) GetGroupData(_ context.Context, groupName string) ([]SyncUser, error)
- func (l *LDAPConn) GetUserByEmail(ctx context.Context, email string) (map[string]any, error)
- func (l *LDAPConn) GetUserByID(ctx context.Context, userID string) (map[string]any, error)
- func (l *LDAPConn) GetUserDN() string
- type LDAPConnClient
- type SyncUser
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoUserFound = errors.New("no LDAP entries found for user")
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
GetGroupData(ctx context.Context, groupDN string) ([]SyncUser, error)
GetUserByEmail(ctx context.Context, email string) (map[string]any, error)
GetUserByID(ctx context.Context, userID string) (map[string]any, error)
}
Client defines the interface for LDAP operations used by the gdrive package.
type Config ¶
type Config struct {
// Server is the LDAP server URL (e.g., "ldap://ldap.example.com:389").
Server string `yaml:"server" json:"server"`
// GroupDN is the base DN for group searches.
GroupDN string `yaml:"groupDN" json:"groupDN"`
// UserDN is the DN template for user lookups (must contain %s for the user ID).
UserDN string `yaml:"userDN" json:"userDN"`
// BaseUserDN is the base DN for user searches.
BaseUserDN string `yaml:"baseUserDN" json:"baseUserDN"`
// UserSearchFilter is the LDAP filter for user searches (e.g., "(objectClass=person)").
UserSearchFilter string `yaml:"userSearchFilter" json:"userSearchFilter"`
// EmailAttribute is the LDAP attribute containing user email addresses (e.g., "mail").
EmailAttribute string `yaml:"emailAttribute" json:"emailAttribute"`
// Attributes is the list of LDAP attributes to retrieve.
Attributes []string `yaml:"attributes" json:"attributes"`
}
Config holds configuration for connecting to an LDAP server.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with generic LDAP defaults.
type LDAPConn ¶
type LDAPConn struct {
// contains filtered or unexported fields
}
LDAPConn manages an LDAP connection and provides query methods.
func (*LDAPConn) GetBaseUserDN ¶
GetBaseUserDN returns the base user DN.
func (*LDAPConn) GetGroupDN ¶
GetGroupDN returns the group DN.
func (*LDAPConn) GetGroupData ¶
GetGroupData retrieves all members of an LDAP group by its common name.
func (*LDAPConn) GetUserByEmail ¶
GetUserByEmail retrieves user data from LDAP using an email address. It searches the base user DN subtree using the configured email attribute.
func (*LDAPConn) GetUserByID ¶
GetUserByID retrieves user data from LDAP using a user ID. It constructs the user DN from the configured template and performs a base object search.
type LDAPConnClient ¶
type LDAPConnClient interface {
IsClosing() bool
Search(*ldap.SearchRequest) (*ldap.SearchResult, error)
UnauthenticatedBind(username string) error
}
LDAPConnClient abstracts the underlying LDAP connection for testability.