Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to filter user in LDAP PHP
    primarykey
    data
    text
    <p>I am using LDAP to login into the system. Currently, I can login to the system using AD account. The problem is, my system have two type of user. (Admin can read and write while the other one is Normal User which only can read). How to filter between these two user so that when Admin login, they will be brought to their HomeScreen.php and Normal User will be brought to HomeScreen2.php. </p> <p>This is the coding for LDAP I've made so far (does not include the login form) : </p> <pre><code>set_time_limit(30); error_reporting(E_ALL); ini_set('error_reporting', E_ALL); ini_set('display_errors',1); ///config $ldapserver = "server.name"; $ldapport = 389; $base_dn = "DC=xyz,DC=local"; $ldapuser = isset($_POST['username']) ? $_POST['username'] : ''; $ldappass = isset($_POST['password']) ? $_POST['password'] : ''; $ldaptree = "CN=ITInfra,OU=Groups,OU=MYABC,DC=xyz,DC=local"; $domain = '@abcd.local'; // connect $ldapconn = ldap_connect($ldapserver,$ldapport) or die ("Could not connect to LDAP server."); // Set some ldap options for talking to ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0); if ($ldapconn) { // binding to ldap server //$ldapbind = @ldap_bind($ldapconn, $ldapuser.$domain, $ldappass) or die ("&lt;b&gt; &lt;center&gt;&lt;font color='red'&gt;WARNING! : ".ldap_error($ldapconn)); $ldapbind = @ldap_bind($ldapconn, $ldapuser.$domain, $ldappass) or die("&lt;b&gt;&lt;center&gt;&lt;font color='red'&gt;WARNING!&lt;br&gt; The username or password you entered is incorrect"); // verify binding if ($ldapbind) { $result = @ldap_search($ldapconn,$ldaptree, "(ou=*)") or die ("&lt;b&gt; &lt;center&gt;&lt;font color='red'&gt;Please enter username &amp; password"); echo "&lt;b&gt;&lt;center&gt;&lt;font color='blue'&gt; Congratulations! $ldapuser is authenticated.\n"; header('Location: HomeScreen.php'); } else { echo "LDAP bind failed...\n"; } } // all done? clean up ldap_close($ldapconn); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload