Jump to content

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

From TetraWiki
Amit (talk | contribs)
No edit summary
Amit (talk | contribs)
No edit summary
Line 38: Line 38:
== PHP CODE DETAILS ==
== PHP CODE DETAILS ==


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


    
    

Revision as of 07:32, 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. "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

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