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

Commit 7c801da

Browse files
committed
Working on Adldap for laravel
1 parent e1f8c00 commit 7c801da

File tree

6 files changed

+260
-2
lines changed

6 files changed

+260
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# adldap2-laravel
2-
Adldap for Laravel
1+
# Adldap2 - Laravel
2+

composer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "adldap2/adldap2-laravel",
3+
"description": "Adldap2 for Laravel 5",
4+
"keywords": ["adldap", "adldap2", "ldap", "laravel"],
5+
"license": "MIT",
6+
"type": "project",
7+
"require": {
8+
"php": ">=5.5.9",
9+
"laravel/framework": "5.*"
10+
},
11+
"require-dev": {
12+
"fzaninotto/faker": "~1.4",
13+
"mockery/mockery": "0.9.*",
14+
"phpunit/phpunit": "~4.0",
15+
"phpspec/phpspec": "~2.1"
16+
},
17+
"archive": {
18+
"exclude": ["/tests"]
19+
},
20+
"autoload": {
21+
"psr-4": {
22+
"Adldap\\": "src/"
23+
}
24+
},
25+
"autoload-dev": {
26+
"psr-4": {
27+
"Adldap\\Tests\\": "tests/"
28+
}
29+
}
30+
}

src/AdldapServiceProvider.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace Adldap\Laravel;
4+
5+
use Adldap\Adldap;
6+
use Adldap\Laravel\Exceptions\ConfigurationMissingException;
7+
use Illuminate\Support\ServiceProvider;
8+
9+
class AdldapServiceProvider extends ServiceProvider
10+
{
11+
/**
12+
* Indicates if loading of the provider is deferred.
13+
*
14+
* @var bool
15+
*/
16+
protected $defer = false;
17+
18+
/**
19+
* Run service provider boot operations.
20+
*/
21+
public function boot()
22+
{
23+
$this->publishes([
24+
__DIR__.'/Config/config.php' => config_path('adldap.php'),
25+
]);
26+
}
27+
28+
/**
29+
* Register the service provider.
30+
*/
31+
public function register()
32+
{
33+
$config = $this->app['config']->get('adldap');
34+
35+
// Verify configuration
36+
if(is_null($config)) {
37+
$message = 'Adldap configuration could not be found. Try re-publishing using `php artisan vendor:publish`.';
38+
39+
throw new ConfigurationMissingException($message);
40+
}
41+
42+
// Bind the Adldap instance to the IoC
43+
$this->app->bind('adldap', function() use ($config)
44+
{
45+
return new Adldap($config['connection_settings'], null, $config['auto_connect']);
46+
});
47+
}
48+
49+
/**
50+
* Get the services provided by the provider.
51+
*
52+
* @return array
53+
*/
54+
public function provides()
55+
{
56+
return ['adldap'];
57+
}
58+
}

src/Config/config.php

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Auto Connect
8+
|--------------------------------------------------------------------------
9+
|
10+
| If auto connect is true, anytime Adldap is instantiated it will automatically
11+
| connect to your AD server.
12+
|
13+
*/
14+
15+
'auto_connect' => true,
16+
17+
/*
18+
|--------------------------------------------------------------------------
19+
| Connection Settings
20+
|--------------------------------------------------------------------------
21+
|
22+
| This connection settings array is directly passed into the Adldap constructor.
23+
|
24+
| Feel free to add or remove settings you don't need.
25+
|
26+
*/
27+
28+
'connection_settings' => [
29+
30+
/*
31+
|--------------------------------------------------------------------------
32+
| Account Suffix
33+
|--------------------------------------------------------------------------
34+
|
35+
| The account suffix option is the suffix of your user accounts in AD.
36+
|
37+
| For example, if your domain DN is DC=corp,DC=acme,DC=org, then your
38+
| account suffix would be @corp.acme.org. This is then appended to
39+
| then end of your user accounts on authentication.
40+
|
41+
*/
42+
43+
'account_suffix' => '@acme.org',
44+
45+
/*
46+
|--------------------------------------------------------------------------
47+
| Domain Controllers
48+
|--------------------------------------------------------------------------
49+
|
50+
| The domain controllers option is an array of servers located on your
51+
| network that serve Active Directory. You insert as many servers or
52+
| as little as you'd like depending on your forest (with the
53+
| minimum of one of course).
54+
|
55+
*/
56+
57+
'domain_controllers' => ['corp-dc1.corp.acme.org', 'corp-dc2.corp.acme.org'],
58+
59+
/*
60+
|--------------------------------------------------------------------------
61+
| Port
62+
|--------------------------------------------------------------------------
63+
|
64+
| The port option is used for authenticating and binding to your AD server.
65+
|
66+
*/
67+
68+
'port' => 389,
69+
70+
/*
71+
|--------------------------------------------------------------------------
72+
| Base Distinguished Name
73+
|--------------------------------------------------------------------------
74+
|
75+
| The base distinguished name is the base distinguished name you'd like
76+
| to perform operations on. An example base DN would be DC=corp,DC=acme,DC=org.
77+
|
78+
| If one is not defined, then Adldap will try to find it automatically
79+
| by querying your server. It's recommended to include it to
80+
| limit queries executed per request.
81+
|
82+
*/
83+
84+
'base_dn' => 'dc=corp,dc=acme,dc=org',
85+
86+
/*
87+
|--------------------------------------------------------------------------
88+
| Administrator Username & Password
89+
|--------------------------------------------------------------------------
90+
|
91+
| When connecting to your AD server, an administrator username and
92+
| password is required to be able to query and run operations on
93+
| your server(s). You can use any user account that has
94+
| these permissions.
95+
|
96+
*/
97+
'admin_username' => 'username',
98+
'admin_password' => 'password',
99+
100+
/*
101+
|--------------------------------------------------------------------------
102+
| Base Distinguished Name
103+
|--------------------------------------------------------------------------
104+
|
105+
| The follow referrals option is a boolean to tell active directory
106+
| to follow a referral to another server on your network if the
107+
| server queried knows the information your asking for exists,
108+
| but does not yet contain a copy of it locally.
109+
|
110+
| This option is defaulted to false.
111+
|
112+
*/
113+
114+
'follow_referrals' => false,
115+
116+
/*
117+
|--------------------------------------------------------------------------
118+
| SSL & TLS
119+
|--------------------------------------------------------------------------
120+
|
121+
| If you need to be able to change user passwords on your server, then an
122+
| SSL or TLS connection is required. All other operations are allowed
123+
| on unsecured protocols. One of these options are definitely recommended
124+
| if you have the ability to connect to your server securely.
125+
|
126+
*/
127+
128+
'use_ssl' => false,
129+
'use_tls' => false,
130+
131+
/*
132+
|--------------------------------------------------------------------------
133+
| SSO (Single Sign On)
134+
|--------------------------------------------------------------------------
135+
|
136+
| If you enable single sign on, be sure you've properly set it up
137+
| on your server before hand.
138+
|
139+
*/
140+
141+
'use_sso' => false,
142+
143+
],
144+
145+
];
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Adldap\Laravel\Exceptions;
4+
5+
class ConfigurationMissingException extends \Exception
6+
{
7+
}

src/Facades/Adldap.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Adldap\Laravel\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
class Adldap extends Facade
8+
{
9+
/**
10+
* Get the registered name of the component.
11+
*
12+
* @return string
13+
*/
14+
protected static function getFacadeAccessor()
15+
{
16+
return 'adldap';
17+
}
18+
}

0 commit comments

Comments
 (0)