TeCategory:Tetra Clients/Upcctns-lko/php-user-creation-page: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| (One intermediate revision 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''' == | ||
| Line 38: | Line 41: | ||
== 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> | ||
# | #"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']); | ||
#echo "Adding user: $cn " . '<br>'; | |||
#$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["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> | ||
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