Replies: 1 comment 8 replies
-
Hi @nikosid, There is no built-in way to do this. PHP is stateless, so LDAP connections are not sustained across requests. This is why we must add configured database credentials into our Laravel applications (as well as LDAP credentials). You will have to store the users LDAP credentials (likely in an encrypted database column), then either override the configured username and password before any connection is made, or by connecting manually. Here's some psuedo-code to show you what I mean: use App\User;
$user = User::first();
[$username, $password] = $user->getLdapCredentials();
config()->set('ldap.connections.default.username', $username);
config()->set('ldap.connections.default.password', $password);
// Begin performing LDAP tasks underneath this user... use App\User;
use LdapRecord\Container;
$user = User::first();
[$username, $password] = $user->getLdapCredentials();
$connection = Container::getDefaultConnection();
$connection->connect($username, $password);
// Begin performing LDAP tasks underneath this user... Hope this helps! |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
Can you help me to understand how to implement logic when we connect to AD with user provided credential but not with LDAP_USERNAME and LDAP_PASSWORD from .env? So the application will use login form not only to authenticate user but also for connection.
Beta Was this translation helpful? Give feedback.
All reactions