Jump to content

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

From TetraWiki
Revision as of 06:41, 15 April 2014 by Amit (talk | contribs)

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