ldap -> auth
This commit is contained in:
@@ -87,22 +87,19 @@ func (cli *Client) Authenticate(ctx context.Context, username string, password s
|
||||
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithCancel(ctx)
|
||||
|
||||
fmt.Println("Connect", ctx, username, password)
|
||||
cn, ok := <-cli.connect(ctx)
|
||||
cancel()
|
||||
if !ok {
|
||||
return false, errConnectionTimeout
|
||||
}
|
||||
defer cn.Close()
|
||||
|
||||
fmt.Println("findBasicUserDetails", cn, username, password)
|
||||
// Find a user DN by his or her username.
|
||||
details, err := cli.findBasicUserDetails(cn, username, []string{"dn"})
|
||||
if err != nil {
|
||||
if err != nil || details == nil {
|
||||
return false, err
|
||||
}
|
||||
if details == nil {
|
||||
return false, nil
|
||||
}
|
||||
a := details["dn"]
|
||||
log.Println("Binding DN:", a[0], "with password:", password)
|
||||
if err := cn.Bind(a[0], password); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user