TeCategory:Tetra Clients/Upcctns-lko/php-user-creation-page
Appearance
UPCCTNS SINGLE USER CREATION LOGIN PAGE
SIMPLE HTML CODE
- <html>
- <head>
- <link rel = "stylesheet" type = "text/css" href = "stylesheets/stylesheet.css">
- <title>Add ldap user</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta http-equiv="Content-Style-Type" content="text/css">
- <meta http-equiv="Content-Script-Type" content="text/javascript">
- <script type="text/javascript">
- function nospaces(t){
- if(t.value.match(/\s/g)){
- alert('Sorry, you are not allowed to enter any spaces');
- t.value=t.value.replace(/\s/g,);
- }
- }
- </script>
- <body>
- use hearder tag here "h1" "Add User" "h1"
- < hr>
- <form action = "ldapuseradd.php" method = "post">
- <label for="username">Username:</label> <input type="text" class="input" id="username" name="username" onkeyup="nospaces(this)" >
<label for = "firstname">First Name:</label> <input class = "input" type ="text" id = "firstname" name="firstname" >
<label for="lastname">Last Name:</label> <input class="input" type ="text" id = "lastname" name="lastname">
<label> </label><input type="submit" value="submit" class="button">- </form>
- </body>
- </head>
- </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 " . '
'; - $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: " . $info[0]["dn"] . " has been created.
"; - }
- }
- 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://192.168.75.201:8080/ldapuseradd.html User : admin Password : admin@upcctns4321 htaccess base restriction