TeCategory:Tetra Clients/Upcctns-lko/php-user-creation-page: Difference between revisions
Appearance
No edit summary |
|||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
[[category:Tetra Clients]] | |||
[[category:Upcctns]] | |||
== '''UPCCTNS SINGLE USER CREATION LOGIN PAGE''' == | == '''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"> | |||
#<p> | |||
#<label for="username">Username:</label> <input type="text" class="input" id="username" name="username" onkeyup="nospaces(this)" > | |||
#<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> </label><input type="submit" value="submit" class="button"> | |||
#</p> | |||
#</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 " . '<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"); | |||
#$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:<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 94: | ||
User : admin | User : admin | ||
Password : admin@upcctns4321 | Password : admin@upcctns4321 | ||
htaccess base restriction | |||
htaccess base restriction | |||
Latest revision as of 11:28, 16 September 2014
UPCCTNS SINGLE USER CREATION LOGIN PAGE[edit]
SIMPLE HTML CODE[edit]
- <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[edit]
- <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[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