Skip to content
This repository was archived by the owner on Feb 16, 2019. It is now read-only.

Commit 0e7afe7

Browse files
committed
Updated for new Adldap2.
1 parent 9796286 commit 0e7afe7

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
Active Directory and LDAP authentication for Kohana
22
===================================================
33

4-
A wrapper module for [Kohana 3.3](http://kohanaframework.org)
5-
to provide Active Directory and LDAP authentication
6-
with the [Adldap2](http://adldap2.github.io) library.
4+
A [Kohana 3.3](http://kohanaframework.org) module
5+
that wraps [Adldap2](https://github.com/Adldap2/Adldap2)
6+
to provide Active Directory and LDAP authentication.
77

88
## 1. Install
99
Copy the module to the `kadldap` directory in your `MODPATH`, or install with
1010
[Composer](https://getcomposer.org) by adding the following to your
1111
`composer.json` file (to get the latest stable version):
1212

13-
"samwilson/kohana_kadldap": "*"
13+
"adldap2/adldap2-kohana": "3.*"
1414

1515
Then enable the module with `Kohana::modules()` (usually in `bootstrap.php`).
1616

@@ -31,3 +31,7 @@ Use [Auth](http://kohanaframework.org/3.3/guide/auth) as usual. e.g.:
3131
or:
3232

3333
Auth::instance()->logged_in('Security Group Name');
34+
35+
## 4. Contribute
36+
37+
Please report all issues at https://github.com/Adldap2/Adldap2-Kohana/issues

classes/Controller/Kadldap.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ public function action_index()
7070
$username = Auth::instance()->get_user();
7171
$password = Auth::instance()->password($username);
7272
$view->kadldap->authenticate($username, $password);
73-
$view->user = $view->kadldap->users()->find($username);
73+
$view->userinfo = $view->kadldap->users()
74+
->find($username)
75+
->getAttributes();
7476
} else {
75-
$view->user = NULL;
77+
$view->userinfo = NULL;
7678
}
7779
}
7880

classes/Kadldap/Auth/LDAP.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,21 @@ public function logged_in($role = NULL)
9191

9292
/**
9393
* Get list of all roles that the current user holds (i.e. LDAP groups
94-
* of which they are a member.
95-
*
96-
* @uses adLDAPUsers::groups()
97-
* @return array An array of strings
94+
* of which they are a member).
95+
*
96+
* @uses Adldap\Models\User::getGroups()
97+
* @return string[]
9898
*/
9999
public function get_roles()
100100
{
101101
$username = $this->get_user();
102102
$this->kadldap->authenticate($username, $this->password($username));
103-
return [];
104-
var_dump($username, $this->kadldap->users());exit();
105103
$user = $this->kadldap->users()->find($username);
106-
$groups = $user->getGroups();
107-
return $groups ? $groups : array();
104+
$groups = array();
105+
foreach ($user->getGroups() as $group) {
106+
$groups[$group->getCommonName()] = $group->getCommonName();
107+
}
108+
return $groups;
108109
}
109110

110111
}

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"name": "samwilson/kohana_kadldap",
2+
"name": "adldap2/adldap2-kohana",
33
"type": "kohana-module",
44
"description": "Module for AD/LDAP support in Kohana 3 (includes an Auth driver).",
55
"license": "MIT",
66
"support": {
7-
"issues": "https://github.com/samwilson/kohana_kadldap/issues",
7+
"issues": "https://github.com/Adldap2/Adldap2-Kohana/issues",
88
"forum": "http://forum.kohanaframework.org",
99
"irc": "irc://irc.freenode.net/kohana",
10-
"source": "https://github.com/samwilson/kohana_kadldap"
10+
"source": "https://github.com/Adldap2/Adldap2-Kohana"
1111
},
1212
"authors": [
1313
{
@@ -25,6 +25,6 @@
2525
],
2626
"require": {
2727
"kohana/auth": "*",
28-
"adldap2/adldap2": "5.0.*"
28+
"adldap2/adldap2": "5.*"
2929
}
3030
}

config/kadldap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
'domain_controllers' => array(), // array('dc.example.com','dc1.example.com')
1313
'account_suffix' => '', // '@example.com'
1414
'base_dn' => '', // 'dc=example,dc=com',
15-
'ad_username' => NULL,
16-
'ad_password' => NULL
15+
'admin_username' => NULL,
16+
'admin_password' => NULL
1717
)
1818
);

0 commit comments

Comments
 (0)