@@ -17,6 +17,7 @@ Adldap2 - Laravel allows easy configuration, access, management and authenticati
1717* [ Installation] ( #installation )
1818* [ Usage] ( #usage )
1919* [ Auth Driver] ( #auth-driver )
20+ * [ Quick Start - From Scratch] ( docs/quick-start.md )
2021 * [ Installation] ( #installation-1 )
2122 * [ Setup] ( #setup )
2223 * Features
@@ -31,8 +32,6 @@ Adldap2 - Laravel allows easy configuration, access, management and authenticati
3132
3233## Installation
3334
34- [ Quick Start - From Scratch] ( docs/quick-start.md )
35-
3635Insert Adldap2-Laravel into your ` composer.json ` file:
3736
3837``` json
@@ -127,135 +126,3 @@ class UserController extends Controller
127126```
128127
129128To see more usage in detail, please visit the [ Adldap2 Repository] ( http://github.com/Adldap2/Adldap2 ) ;
130-
131- ## Auth Driver
132-
133- The Adldap Laravel auth driver allows you to seamlessly authenticate AD users,
134- as well as have a local database record of the user.
135-
136- This allows you to easily attach information to the users account
137- as you would a regular laravel application.
138-
139- > ** Note** : The Adldap auth driver actually extends from and utilizes Laravel's eloquent auth driver.
140-
141- ### Installation
142-
143- #### Laravel 5.1
144-
145- Insert the ` AdldapAuthServiceProvider ` into your ` config/app.php ` file:
146-
147- ``` php
148- Adldap\Laravel\AdldapAuthServiceProvider::class,
149- ```
150-
151- Publish the auth configuration:
152-
153- ``` bash
154- php artisan vendor:publish --tag=" adldap"
155- ```
156-
157- Change the auth driver in ` config/auth.php ` to ` adldap ` :
158-
159- ``` php
160- 'driver' => 'adldap',
161- ```
162-
163- #### Laravel 5.2 & Up
164-
165- Insert the ` AdldapAuthServiceProvider ` into your ` config/app.php ` file:
166-
167- ``` php
168- Adldap\Laravel\AdldapAuthServiceProvider::class,
169- ```
170-
171- Publish the auth configuration:
172-
173- ``` bash
174- php artisan vendor:publish --tag=" adldap"
175- ```
176-
177- Open your ` config/auth.php ` configuration file and change the following:
178-
179- Change the ` driver ` value inside the ` users ` authentication provider to ` adldap ` :
180-
181- ``` php
182- 'providers' => [
183- 'users' => [
184- 'driver' => 'adldap', // Changed from 'eloquent'
185- 'model' => App\User::class,
186- ],
187- ],
188- ```
189-
190- ### Setup
191-
192- #### Usernames
193-
194- Inside your ` config/adldap_auth.php ` file there is a configuration option named ` usernames ` .
195-
196- This array contains the ` ldap ` attribute you use for authenticating users, as well
197- as the ` eloquent ` attribute for locating the LDAP users model.
198-
199- ``` php
200-
201- 'usernames' => [
202-
203- 'ldap' => 'userprincipalname',
204-
205- 'eloquent' => 'email',
206-
207- ],
208- ```
209-
210- If you're using a ` username ` field instead of ` email ` in your application, you will need to change this configuration.
211-
212- > ** Note** : Keep in mind you will also need to update your ` database/migrations/2014_10_12_000000_create_users_table.php `
213- > migration to use a username field instead of email, ** as well as** your LoginController.
214-
215- For example, if you'd like to login users by their ` samaccountname ` :
216-
217- ``` php
218-
219- 'usernames' => [
220-
221- 'ldap' => 'samaccountname',
222-
223- 'eloquent' => 'username',
224-
225- ],
226- ```
227-
228- Be sure to update the ` sync_attributes ` option to synchronize the users ` username ` as well:
229-
230- ``` php
231- 'sync_attributes' => [
232-
233- 'username' => 'samaccountname', // Changed from 'email' => 'userprincipalname'
234- 'name' => 'cn',
235-
236- ],
237- ```
238-
239- #### Logging In
240-
241- Login a user regularly using ` Auth::attempt($credentials); ` .
242-
243- Once a user is authenticated, retrieve them as you would regularly:
244-
245- ``` php
246- public function login(Request $request)
247- {
248- if (Auth::attempt($request->only(['email', 'password'])) {
249-
250- // Returns \App\User model configured in `config/auth.php`.
251- $user = Auth::user();
252-
253-
254- return redirect()->to('home')
255- ->withMessage('Logged in!');
256- }
257-
258- return redirect()->to('login')
259- ->withMessage('Hmm... Your username or password is incorrect');
260- }
261- ```
0 commit comments