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 1: Line 1:
[[category:Tetra Clients]]
[[category:Upcctns]]


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

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