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
Line 3: Line 3:




<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>
# Use Header tag "h1" "Adding LDAP User" "h1"
# < hr>
# <?php
# $cn = htmlspecialchars($_POST['username']);
# $givenName = htmlspecialchars($_POST['firstname']);
# $surname = htmlspecialchars($_POST['lastname']);
# $mail_host = "mail.upcctns.gov.in";
# $mailmsgstore = "upcctns.gov.in/$cn";
# 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");
# $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["mailHost"] = $mail_host;
# $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 87:
  User : admin
  User : admin
  Password : admin@upcctns4321
  Password : admin@upcctns4321
 
htaccess base restriction
htaccess base restriction

Revision as of 06:41, 15 April 2014

UPCCTNS SINGLE USER CREATION LOGIN PAGE

SIMPLE HTML CODE

  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

  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. Use Header tag "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. $mail_host = "mail.upcctns.gov.in";
  14. $mailmsgstore = "upcctns.gov.in/$cn";
  15. echo "Adding user: $cn " . '
    ';
  16. $ds = ldap_connect("localhost") or die ("Could not connect to LDAP Server");
  17. if ($ds) {
  18. $r = ldap_bind($ds,"cn=manager,dc=upcctns,dc=gov,dc=in","secret");
  19. $info["cn"] = $cn;
  20. $info["uid"] = $cn;
  21. $info["givenName"] = $givenName;
  22. $info["surname"] = $surname;
  23. $info["objectClass"][0] = "inetOrgPerson";
  24. $info['objectClass'][1] = "top";
  25. $info['objectClass'][2] = "qmailUser";
  26. $info["mail"] = "$cn@upcctns.gov.in";
  27. $info["mailHost"] = $mail_host;
  28. $info["mailMessageStore"] = "upcctns.gov.in/$cn";
  29. $info["userPassword"] = "{SSHA}ge+eLYjTpH+su5WMy0N8PZpvnURYq6kC";
  30. $r = ldap_add($ds,"uid=$cn,ou=upcctns.gov.in,dc=upcctns,dc=gov,dc=in",$info);
  31. $sr = ldap_search($ds,"dc=upcctns,dc=gov,dc=in","uid=$cn");
  32. $info = ldap_get_entries($ds,$sr);
  33. echo "The user: " . $info[0]["dn"] . " has been created.
    ";
  34. }
  35. ldap_close($ds);
  36. ?>
  37. < hr>
  38. <a href = "ldapuseradd.html">Add another user</a>
  39. </body>
  40. </html>


Login Details

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