Jump to content

TeCategory:Tetra Clients/Upcctns-lko/php-user-creation-page: Difference between revisions

From TetraWiki
Amit (talk | contribs)
Amit (talk | contribs)
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[category:Tetra Clients]]
[[category:Upcctns]]


== '''UPCCTNS SINGLE USER CREATION LOGIN PAGE''' ==
== '''UPCCTNS SINGLE USER CREATION LOGIN PAGE''' ==




<html>
== SIMPLE HTML CODE ==
<head>
<link rel = "stylesheet" type = "text/css" href = "stylesheets/stylesheet.css">
<title>Add ldap user</title>
<body>
<h1>Add User</h1>
<hr>
<form action = "ldapuseradd.php" method = "post">
<p>
<label for="username">Username:</label> <input type="text" class="input" id="username" name="username">
<br><label for = "firstname">First Name:</label> <input class = "input" type ="text" id = "firstname" name="firstname" >
<br><label for="lastname">Last Name:</label> <input class="input" type ="text" id = "lastname" name="lastname">
  <br><label>&nbsp</label><input type="submit" value="submit" class="button">
</p>
</form>
</body>
</head>
</html>


***************************************************************
#<html>
<html>
#<head>
<head>
#<link rel = "stylesheet" type = "text/css" href = "stylesheets/stylesheet.css">
<link rel = "stylesheet" type = "text/css" href = "stylesheets/stylesheet.css">
#<title>Add ldap user</title>
<title>PHP LDAP Add</title>
#<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head?
#<meta http-equiv="Content-Style-Type" content="text/css">
<body>
#<meta http-equiv="Content-Script-Type" content="text/javascript">
<h1> Adding LDAP User</h1>
#<script type="text/javascript">
<hr>
#function nospaces(t){
<?php
#if(t.value.match(/\s/g)){
$cn = htmlspecialchars($_POST['username']);
#alert('Sorry, you are not allowed to enter any spaces');
$givenName = htmlspecialchars($_POST['firstname']);
#t.value=t.value.replace(/\s/g,'');
$surname = htmlspecialchars($_POST['lastname']);
#}
$mail_host = "mail.upcctns.gov.in";
#}
$mailmsgstore = "upcctns.gov.in/$cn";
#</script>
echo "Adding user: $cn " . '<br>';
#<body>
$ds = ldap_connect("localhost") or die ("Could not connect to LDAP Server");
## use hearder tag here "h1" "Add User" "h1"
if ($ds) {
#< hr>
$r = ldap_bind($ds,"cn=manager,dc=upcctns,dc=gov,dc=in","secret");
#<form action = "ldapuseradd.php" method = "post">
$info["cn"] = $cn;
#<p>
$info["uid"] = $cn;
#<label for="username">Username:</label> <input type="text" class="input" id="username" name="username" onkeyup="nospaces(this)" >
$info["givenName"] = $givenName;
#<br><label for = "firstname">First Name:</label> <input class = "input" type ="text" id = "firstname" name="firstname" >
$info["surname"] = $surname;
#<br><label for="lastname">Last Name:</label> <input class="input" type ="text" id = "lastname" name="lastname">
$info["objectClass"][0] = "inetOrgPerson";
#<br><label>&nbsp</label><input type="submit" value="submit" class="button">
$info['objectClass'][1] = "top";
#</p>
//$info['objectClass'] = "inetOrgPerson";
#</form>
$info['objectClass'][2] = "qmailUser";
#</body>
$info["mail"] = "$cn@upcctns.gov.in";
#</head>
//$info["mailHost"] = $mail_host;
#</html>
$info["mailMessageStore"] = "upcctns.gov.in/$cn";
$info["userPassword"] = "{SSHA}ge+eLYjTpH+su5WMy0N8PZpvnURYq6kC";
$r = ldap_add($ds,"uid=$cn,ou=upcctns.gov.in,dc=upcctns,dc=gov,dc=in",$info);
$sr = ldap_search($ds,"dc=upcctns,dc=gov,dc=in","uid=$cn");
$info = ldap_get_entries($ds,$sr);
echo "The user:<span class='result'> " . $info[0]["dn"] . "</span> has been created. <br>";
}
ldap_close($ds);
?>
<hr>
<a href = "ldapuseradd.html">Add another user</a>
</body>
</html>  


**************************************************************************************************
 
== PHP CODE DETAILS ==
 
#<html>
#<head>
#<link rel = "stylesheet" type = "text/css" href = "stylesheets/stylesheet.css">
#<title>PHP LDAP Add</title>
#</head?
#<body>
#"h1" Adding LDAP User"h1"
#< hr>
#<?php
#$cn = htmlspecialchars($_POST['username']);
#$givenName = htmlspecialchars($_POST['firstname']);
#$surname = htmlspecialchars($_POST['lastname']);
#echo "Adding user: $cn " . '<br>';
#$ds = ldap_connect("localhost") or die ("Could not connect to LDAP Server");
#if ($ds) {
#$r = ldap_bind($ds,"cn=manager,dc=upcctns,dc=gov,dc=in","secret");
#$chk_val = ldap_search($ds,"dc=upcctns,dc=gov,dc=in","uid=$cn");
#$chk = ldap_get_entries($ds,$chk_val);
#$val = array_count_values($chk);
#print_r($val);
#if (in_array("1" , $chk)) {
#echo " User Already Exsist Contact Admin For Detail " . $chk[0]["dn"] . " "; }
#else {
#$info["cn"] = $cn;
#$info["uid"] = $cn;
#$info["givenName"] = $givenName;
#$info["surname"] = $surname;
#$info["objectClass"][0] = "inetOrgPerson";
#$info['objectClass'][1] = "top";
#$info['objectClass'][2] = "qmailUser";
#$info["mail"] = "$cn@upcctns.gov.in";
#$info["mailMessageStore"] = "upcctns.gov.in/$cn";
#$info["userPassword"] = "{SSHA}ge+eLYjTpH+su5WMy0N8PZpvnURYq6kC";
#$r = ldap_add($ds,"uid=$cn,ou=upcctns.gov.in,dc=upcctns,dc=gov,dc=in",$info);
#$sr = ldap_search($ds,"dc=upcctns,dc=gov,dc=in","uid=$cn");
#$info = ldap_get_entries($ds,$sr);
#echo "The user:<span class='result'> " . $info[0]["dn"] . "</span> has been created. <br>";
#}
# }
#ldap_close($ds);
#?>
#< hr>
#<a href = "ldapuseradd.html">Add another user</a>
#</body>
#</html>
 
 
== Login Details ==


  http://164.100.181.134/padmin/ldapuseradd.html
  http://164.100.181.134/padmin/ldapuseradd.html
Line 71: Line 94:
  User : admin
  User : admin
  Password : admin@upcctns4321
  Password : admin@upcctns4321
 
htaccess base restriction
htaccess base restriction

Latest revision as of 11:28, 16 September 2014


UPCCTNS SINGLE USER CREATION LOGIN PAGE[edit]

SIMPLE HTML CODE[edit]

  1. <html>
  2. <head>
  3. <link rel = "stylesheet" type = "text/css" href = "stylesheets/stylesheet.css">
  4. <title>Add ldap user</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <meta http-equiv="Content-Style-Type" content="text/css">
  7. <meta http-equiv="Content-Script-Type" content="text/javascript">
  8. <script type="text/javascript">
  9. function nospaces(t){
  10. if(t.value.match(/\s/g)){
  11. alert('Sorry, you are not allowed to enter any spaces');
  12. t.value=t.value.replace(/\s/g,);
  13. }
  14. }
  15. </script>
  16. <body>
    1. use hearder tag here "h1" "Add User" "h1"
  17. < hr>
  18. <form action = "ldapuseradd.php" method = "post">
  19. <label for="username">Username:</label> <input type="text" class="input" id="username" name="username" onkeyup="nospaces(this)" >

  20. <label for = "firstname">First Name:</label> <input class = "input" type ="text" id = "firstname" name="firstname" >

  21. <label for="lastname">Last Name:</label> <input class="input" type ="text" id = "lastname" name="lastname">

  22. <label>&nbsp</label><input type="submit" value="submit" class="button">
  23. </form>
  24. </body>
  25. </head>
  26. </html>


PHP CODE DETAILS[edit]

  1. <html>
  2. <head>
  3. <link rel = "stylesheet" type = "text/css" href = "stylesheets/stylesheet.css">
  4. <title>PHP LDAP Add</title>
  5. </head?
  6. <body>
  7. "h1" Adding LDAP User"h1"
  8. < hr>
  9. <?php
  10. $cn = htmlspecialchars($_POST['username']);
  11. $givenName = htmlspecialchars($_POST['firstname']);
  12. $surname = htmlspecialchars($_POST['lastname']);
  13. echo "Adding user: $cn " . '
    ';
  14. $ds = ldap_connect("localhost") or die ("Could not connect to LDAP Server");
  15. if ($ds) {
  16. $r = ldap_bind($ds,"cn=manager,dc=upcctns,dc=gov,dc=in","secret");
  17. $chk_val = ldap_search($ds,"dc=upcctns,dc=gov,dc=in","uid=$cn");
  18. $chk = ldap_get_entries($ds,$chk_val);
  19. $val = array_count_values($chk);
  20. print_r($val);
  21. if (in_array("1" , $chk)) {
  22. echo " User Already Exsist Contact Admin For Detail " . $chk[0]["dn"] . " "; }
  23. else {
  24. $info["cn"] = $cn;
  25. $info["uid"] = $cn;
  26. $info["givenName"] = $givenName;
  27. $info["surname"] = $surname;
  28. $info["objectClass"][0] = "inetOrgPerson";
  29. $info['objectClass'][1] = "top";
  30. $info['objectClass'][2] = "qmailUser";
  31. $info["mail"] = "$cn@upcctns.gov.in";
  32. $info["mailMessageStore"] = "upcctns.gov.in/$cn";
  33. $info["userPassword"] = "{SSHA}ge+eLYjTpH+su5WMy0N8PZpvnURYq6kC";
  34. $r = ldap_add($ds,"uid=$cn,ou=upcctns.gov.in,dc=upcctns,dc=gov,dc=in",$info);
  35. $sr = ldap_search($ds,"dc=upcctns,dc=gov,dc=in","uid=$cn");
  36. $info = ldap_get_entries($ds,$sr);
  37. echo "The user: " . $info[0]["dn"] . " has been created.
    ";
  38. }
  39. }
  40. ldap_close($ds);
  41. ?>
  42. < hr>
  43. <a href = "ldapuseradd.html">Add another user</a>
  44. </body>
  45. </html>


Login Details[edit]

http://164.100.181.134/padmin/ldapuseradd.html
http://192.168.75.201:8080/ldapuseradd.html
User : admin
Password : admin@upcctns4321
htaccess base restriction