w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Single-Sign-On from Windows Workstation to PHP script running on Linux server that is not part of the same domain


I actually just implemented a basic LDAP authentication script. This was my first draft of the script before I changed and messed with it to fit with my setup. This basically connects to the server, if not the scrpt is killed. Then tries to authenticate the given username and password, if not, it fails. Quick and simple.

$ldapHost = "example2.com";
$ldapPort = 666;
$ldapBaseDn = "ldap base dn here";
$username = "username";
$password = "password";
$ldapUserDn = "uid=$username,".$ldapBaseDn;

echo "LDAP query test
echo "Connecting ...
$ldapConn = ldap_connect($ldapHost, $ldapPort)
    or die("Unable to connect to LDAP server: $ldapHost

echo "Authenticating user ...
$isValid = ldap_bind($ldapConn, $ldapUserDn, $password)
    or die("Unable to authenticate user: $username

echo "User $username is successfully authenticated!

echo "Closing connection ...



© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.