-
Notifications
You must be signed in to change notification settings - Fork 5
/
login.php
70 lines (53 loc) · 2.51 KB
/
login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<link href="css/bootstrap.css" rel="stylesheet">
<?php
if(isset($_POST['userid']) && isset($_POST['password'])){
$adServer = "ldap://msc-dc01.iccu.com";
$ldap = ldap_connect($adServer);
$username = $_POST['userid'];
$password = $_POST['password'];
$ldaprdn = 'ICCU1' . "\\" . $username;
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
$bind = @ldap_bind($ldap, $ldaprdn, $password);
if ($bind) {
$filter="(sAMAccountName=$username)";
$result = ldap_search($ldap,"dc=ICCU,dc=COM",$filter);
ldap_sort($ldap,$result,"sn");
$info = ldap_get_entries($ldap, $result);
for ($i=0; $i<$info["count"]; $i++)
{
session_start();
//$username = $info[$i]["givenname"][0] . ' ' . $info[$i]["sn"][0];
$_SESSION["agentname"] = $_POST['userid'];
header('Location: MCCSurvey.php');
}
@ldap_close($ldap);
} else {
?>
<div class="panel panel-primary" style="width:25%; margin: 0 auto;">
<div class="panel-heading">MCC Survey<br></div>
<div class="panel-body">
<form action="#" method="POST">
<input class="form-control" id="userid" type="text" name="userid" placeholder="Username" />
<input class="form-control" id="password" type="password" name="password" placeholder="Password" /> <br>
<input class="btn btn-primary"style="width:100%; margin:0 auto;" type="submit" name="submit" value="Login" />
</form>
</div>
</div>
<?php
//echo $msg;
}
} else{
?>
<br><br><br><br><br><br>
<div class="panel panel-primary" style="width:25%; margin: 0 auto;">
<div class="panel-heading">MCC Survey<br></div>
<div class="panel-body">
<form action="#" method="POST">
<input class="form-control" id="userid" type="text" name="userid" placeholder="Username" />
<input class="form-control" id="password" type="password" name="password" placeholder="Password" /> <br>
<input class="btn btn-primary"style="width:100%; margin:0 auto;" type="submit" name="submit" value="Login" />
</form>
</div>
</div>
<?php } ?>