Hi there,
I have this login script that allows the user to login through LDAP authentication. What I am trying to achieve with no luck is to hide the form after successful login. Can anyone assist me please?
The form:
<form action="login" method="post" enctype="application/x-www-form-urlencoded">
<label>username</label>
<input type="text" required name="userLogin" title="Username required" data-icon="U" autofocus>
<br><br>
<label>Password</label>
<input type="password" required name="userPassword" title="Password required" data-icon="x">
<input class="send" type="submit" name="submit" value="Login" />
</form>
The authentication method:
// verify user and password
if($bind = @ldap_bind($ldap, $user . $ldap_usr_dom, $password)) {
// valid
// check presence in groups
$filter = "(sAMAccountName=" . $user . ")";
$attr = array("memberof","cn","mail","givenName");
$result = ldap_search($ldap, $ldap_dn, $filter, $attr);
$entries = ldap_get_entries($ldap, $result);
ldap_unbind($ldap);
// check groups
foreach($entries[0]['memberof'] as $grps) {
// is manager, break loop
if (strpos($grps, $ldap_manager_group)) { $access = 2; break; }
// is user
if (strpos($grps, $ldap_user_group)) $access = 1;
}
if ($access != 0) {
// establish session variables
$_SESSION['user'] = $user;
$_SESSION['access'] = $access;
$_SESSION['name'] = $entries[0]['cn'][0];
$_SESSION['email'] = $entries[0]['mail'][0];
$_SESSION['givenname'] = $entries[0]['givenname'][0];
return true;
} else {
// user has no rights
return false;
}
} else {
// invalid name or password
return false;
}
}