Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if ($_POST["dn"] && $_SESSION["auth"]="Y"){
- $dn = $_POST["dn"];
- $user=$_SESSION["username"];
- $pass=$_SESSION["password"];
- $server=$_SESSION["server"];
- $ds = ldap_connect($server);
- if($ds){
- ldap_set_option($ds,LDAP_OPT_PROTOCOL_VERSION,3);
- $r = ldap_bind($ds,$user,$pass);
- $temp=strpos($dn,",");
- $cn=substr($dn,0,$temp);
- //(it will be $cn=substr($dn,3,$temp-3); in active directory, why?)
- $info["cn"] = $cn;
- $info["sn"] = $cn;
- $info["objectclass"] = "person";
- ldap_add($ds, $dn, $info);
- echo “user $dn was addeded!”
- ldap_close($ds);
- }else{ echo "unable to connect <br>"; }
- }
- ?>
Add Comment
Please, Sign In to add comment