Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit df73b9e

Browse files
committed
Added bind as user option.
- This new option allows you to bind as a user instead of providing administrator credentials.
1 parent 73c0229 commit df73b9e

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

src/AdldapAuthUserProvider.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected function discoverAdldapFromModel($model)
120120
*/
121121
protected function authenticate($username, $password)
122122
{
123-
return $this->getAdldap()->auth()->attempt($username, $password);
123+
return $this->getAdldap()->auth()->attempt($username, $password, $this->getBindAsUser());
124124
}
125125

126126
/**
@@ -144,4 +144,15 @@ protected function getLoginFallback()
144144
{
145145
return Config::get('adldap_auth.login_fallback', false);
146146
}
147+
148+
/**
149+
* Retrieves the Adldap bind as user option for binding
150+
* as the authenticated user.
151+
*
152+
* @return bool
153+
*/
154+
protected function getBindAsUser()
155+
{
156+
return Config::get('adldap_auth.bind_as_user', false);
157+
}
147158
}

src/Config/auth.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
|
1212
| You must specify connections in your `config/adldap.php` configuration file.
1313
|
14+
| This must be a string.
15+
|
1416
*/
1517

1618
'connection' => env('ADLDAP_CONNECTION', 'default'),
@@ -30,6 +32,8 @@
3032
| by their emails, then change `samaccountname` to `mail`.
3133
| and `username` to `email`.
3234
|
35+
| This must be an array with a key - value pair.
36+
|
3337
*/
3438

3539
'username_attribute' => ['username' => 'samaccountname'],
@@ -58,6 +62,8 @@
5862
|
5963
| Set this to true if you would like to enable it.
6064
|
65+
| This option must be true or false.
66+
|
6167
*/
6268

6369
'login_fallback' => env('ADLDAP_LOGIN_FALLBACK', false),
@@ -72,6 +78,8 @@
7278
|
7379
| Change this if you change your password fields input name.
7480
|
81+
| This option must be a string.
82+
|
7583
*/
7684

7785
'password_key' => env('ADLDAP_PASSWORD_KEY', 'password'),
@@ -85,6 +93,8 @@
8593
| that you use to log users in. For example, if your company uses
8694
| email, then insert `mail`.
8795
|
96+
| This option must be a string.
97+
|
8898
*/
8999

90100
'login_attribute' => env('ADLDAP_LOGIN_ATTRIBUTE', 'samaccountname'),
@@ -94,7 +104,7 @@
94104
| Bind User to Model
95105
|--------------------------------------------------------------------------
96106
|
97-
| The bind User to Model option allows you to access the Adldap user model
107+
| The bind user to model option allows you to access the Adldap user model
98108
| instance on your laravel database model to be able run operations
99109
| or retrieve extra attributes on the Adldap user model instance.
100110
|
@@ -106,10 +116,27 @@
106116
|
107117
| Then use `Auth::user()->adldapUser` to access.
108118
|
119+
| This option must be true or false.
120+
|
109121
*/
110122

111123
'bind_user_to_model' => env('ADLDAP_BIND_USER_TO_MODEL', false),
112124

125+
/*
126+
|--------------------------------------------------------------------------
127+
| Bind As User
128+
|--------------------------------------------------------------------------
129+
|
130+
| The bind as user option will bind to your AD server as the
131+
| authenticated user. This is useful if you don't want to
132+
| provide administrator credentials.
133+
|
134+
| This option must be true or false.
135+
|
136+
*/
137+
138+
'bind_as_user' => env('ADLDAP_BIND_AS_USER', false),
139+
113140
/*
114141
|--------------------------------------------------------------------------
115142
| Sync Attributes

0 commit comments

Comments
 (0)