You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1010 B
33 lines
1010 B
<?php |
|
|
|
$host = getenv('LDAP_HOST') ?: '10.100.1.40'; |
|
$base = getenv('LDAP_BASE_DN') ?: 'DC=gisportal,DC=id'; |
|
$dns = [ |
|
'CN=ldapadmin,CN=Users,DC=gisportal,DC=id', |
|
'ldapadmin@gisportal.id', |
|
'CN=Administrator,CN=Users,DC=gisportal,DC=id', |
|
'Administrator@gisportal.id', |
|
]; |
|
$passwords = array_values(array_unique(array_filter([ |
|
getenv('LDAP_BIND_PASSWORD'), |
|
getenv('ADMIN_PASSWORD'), |
|
getenv('MSSQL_PASSWORD'), |
|
]))); |
|
|
|
foreach ($dns as $dn) { |
|
foreach ($passwords as $pw) { |
|
$c = ldap_connect("ldap://{$host}:389"); |
|
ldap_set_option($c, LDAP_OPT_PROTOCOL_VERSION, 3); |
|
ldap_set_option($c, LDAP_OPT_REFERRALS, 0); |
|
|
|
if (@ldap_bind($c, $dn, $pw)) { |
|
$r = @ldap_search($c, $base, '(&(objectCategory=person)(objectClass=user))', ['samaccountname'], 0, 3); |
|
$e = ldap_get_entries($c, $r); |
|
echo "bind_ok dn={$dn} users=" . ($e['count'] ?? 0) . PHP_EOL; |
|
exit(0); |
|
} |
|
} |
|
} |
|
|
|
echo "bind_none" . PHP_EOL; |
|
exit(1);
|
|
|