Some may wonder how it’s possible but this is definitely possible as long as you host wordpress on IIS. I was able to even auto login in the user without the user signing up for the wordpress!
I will explain step by step procedure of how to do this with wordpress and IIS.
Step 1: Host the wordpress with IIS
Step 2: Install Custom PHP functions editor
Step 3: Add the below code to the plugin and toggle on the “On switch”
function auto_login() {
if (!is_user_logged_in())
{
$url=$_SERVER['HTTP_REFERER'];
echo "<script>";
echo "window.top.location.href = 'https://wordpressite.com/ldapauth.php?url=$url'";
echo "</script>";
}
}
add_action('wp', 'auto_login');
What the above code does?
It checks whether the user has logged in, if not it redirects the user to ldapauth.php script along with referrer url.
Let us see more about what ldapauth script does over here and how to authenticate ldap user with wordpress DB!