Documentation
¶
Overview ¶
Package ldap provides a simple ldap client to authenticate, retrieve basic information and groups for a user.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LDAPClient ¶
type LDAPClient struct { Base string BindDN string BindPassword string GroupFilter string // e.g. "(memberUid=%s)" Host string ServerName string UserFilter string // e.g. "(uid=%s)" Conn *ldap.Conn Port int InsecureSkipVerify bool UseSSL bool SkipTLS bool UserUID string GroupGID string ClientCertificates []tls.Certificate // Adding client certificates }
func (*LDAPClient) Authenticate ¶
func (lc *LDAPClient) Authenticate(username, password string) (bool, []string, error)
Authenticate authenticates the user against the ldap backend.
Example ¶
ExampleLDAPClient_Authenticate shows how a typical application can verify a login attempt
client := &ldap.LDAPClient{ Base: "dc=example,dc=com", Host: "ldap.example.com", Port: 389, UseSSL: false, BindDN: "uid=readonlysuer,ou=People,dc=example,dc=com", BindPassword: "readonlypassword", UserFilter: "(uid=%s)", GroupFilter: "(memberUid=%s)", Attributes: []string{"givenName", "sn", "mail", "uid"}, } defer client.Close() ok, user, err := client.Authenticate("username", "password") if err != nil { log.Fatalf("Error authenticating user %s: %+v", "username", err) } if !ok { log.Fatalf("Authenticating failed for user %s", "username") } log.Printf("User: %+v", user)
Output:
func (*LDAPClient) Connect ¶
func (lc *LDAPClient) Connect() error
Connect connects to the ldap backend.
Click to show internal directories.
Click to hide internal directories.