Guest User

Untitled

a guest
Apr 14th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if ($_POST["dn"] && $_SESSION["auth"]="Y"){
  4. $dn = $_POST["dn"];
  5. $user=$_SESSION["username"];
  6. $pass=$_SESSION["password"];
  7. $server=$_SESSION["server"];
  8. $ds = ldap_connect($server);
  9. if($ds){
  10. ldap_set_option($ds,LDAP_OPT_PROTOCOL_VERSION,3);
  11. $r = ldap_bind($ds,$user,$pass);
  12. $temp=strpos($dn,",");
  13. $cn=substr($dn,0,$temp);
  14. //(it will be $cn=substr($dn,3,$temp-3); in active directory, why?)
  15. $info["cn"] = $cn;
  16. $info["sn"] = $cn;
  17. $info["objectclass"] = "person";
  18. ldap_add($ds, $dn, $info);
  19. echo “user $dn was addeded!”
  20. ldap_close($ds);
  21. }else{ echo "unable to connect <br>"; }
  22. }
  23. ?>
Add Comment
Please, Sign In to add comment