Skip to content

Commit a83d273

Browse files
committed
Updated auth
1 parent c2d438d commit a83d273

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

pkg/ldap/cmd/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type AuthCommands struct {
1818
}
1919

2020
type AuthBindCommand struct {
21-
ObjectGetCommand
21+
DN string `arg:"" help:"User or DN"`
2222
Password string `required:"" help:"Password"`
2323
}
2424

pkg/ldap/manager.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,13 @@ func (manager *Manager) Bind(ctx context.Context, dn, password string) (*schema.
462462
return nil, httpresponse.ErrGatewayError.With("Not connected")
463463
}
464464

465+
// If the dn is an identifier, assume it is a user and we need to make an RDN
466+
if types.IsIdentifier(dn) && manager.users != nil {
467+
if user, err := manager.users.New(dn, nil); err == nil {
468+
dn = user.DN
469+
}
470+
}
471+
465472
// Make absolute DN
466473
absdn, err := manager.absdn(dn)
467474
if err != nil {
@@ -504,6 +511,13 @@ func (manager *Manager) ChangePassword(ctx context.Context, dn, old string, new
504511
return nil, httpresponse.ErrBadRequest.With("New password parameter is required")
505512
}
506513

514+
// If the dn is an identifier, assume it is a user and we need to make an RDN
515+
if types.IsIdentifier(dn) && manager.users != nil {
516+
if user, err := manager.users.New(dn, nil); err == nil {
517+
dn = user.DN
518+
}
519+
}
520+
507521
// Make absolute DN
508522
absdn, err := manager.absdn(dn)
509523
if err != nil {

0 commit comments

Comments
 (0)