active-directory-login
Gesponsorde koppelingen
PHP script bestanden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* @author Marijn van der Kruijt
*/
$username = $_POST['username'];
$password = $_POST['password'];
$domeinserver = "domainserver";
$domein = "domain";
$usergroep = "CN=USERGROUP,OU=EU,DC=domain,DC=com";
$ds=ldap_connect($domeinserver);
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
$r = @ldap_bind($ds, $domein."\\".$username, $password);
if ($r) {
$sr= ldap_search($ds, $usergroep, "CN=*");
$info = ldap_get_entries($ds, $sr);
for ($i=0; $i<$info["count"]; $i++) {
for ($b=0; $b<count($info[0]["member"])-1; $b++) {
$zoek = $info[0]["member"][$b];
$nr=ldap_search($ds, $zoek, "CN=*");
$ninfo = ldap_get_entries($ds, $nr);
$userstring = $ninfo[0][userprincipalname][0];
list($loginnaam, $achterstuk) = split('[@]', $userstring);
$ingroep = ((strtolower($username) == strtolower($loginnaam)) ? 1 : 0);
switch($ingroep){
case 0: echo "Geen lid"; break;
case 1: echo "Wel lid"; break;
}
}
}
} else { echo "Uw gebruikesnaam of wachtwoord is incorrect..." ; }
ldap_close($ds);
?>
/**
* @author Marijn van der Kruijt
*/
$username = $_POST['username'];
$password = $_POST['password'];
$domeinserver = "domainserver";
$domein = "domain";
$usergroep = "CN=USERGROUP,OU=EU,DC=domain,DC=com";
$ds=ldap_connect($domeinserver);
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
$r = @ldap_bind($ds, $domein."\\".$username, $password);
if ($r) {
$sr= ldap_search($ds, $usergroep, "CN=*");
$info = ldap_get_entries($ds, $sr);
for ($i=0; $i<$info["count"]; $i++) {
for ($b=0; $b<count($info[0]["member"])-1; $b++) {
$zoek = $info[0]["member"][$b];
$nr=ldap_search($ds, $zoek, "CN=*");
$ninfo = ldap_get_entries($ds, $nr);
$userstring = $ninfo[0][userprincipalname][0];
list($loginnaam, $achterstuk) = split('[@]', $userstring);
$ingroep = ((strtolower($username) == strtolower($loginnaam)) ? 1 : 0);
switch($ingroep){
case 0: echo "Geen lid"; break;
case 1: echo "Wel lid"; break;
}
}
}
} else { echo "Uw gebruikesnaam of wachtwoord is incorrect..." ; }
ldap_close($ds);
?>