title: Add password user using LDAP PHP
body: <p>I searched every days for my problem, I tried many solutions and I didn't find... :( </p>
  
  <p>I want to create an user using ldap_add with PHP. Working fine without enable account and without password. You find the code below.</p>
  
  <p>Can you help me, please? </p>
  
  <p><strong>Config</strong> : 
  PHP 5.6 
  Windows Server 2012 R2 with AD</p>
  
  <p>I can enable an account when I use <code>$info["useraccountcontrol"]=544;</code> but the account isn't with a password... User must loggon without password and type his new password at the first connection. *</p>
  
  <p>I tried to add a password with <code>$info['userPassword']</code>  and chand useraccountontrol at 512 and I get this error : </p>
  
  <p><strong><em>ldap_add(): Add: Server is unwilling to perform</em></strong></p>
  
  <p>Here is my code : </p>
  
  <pre><code>&lt;?php
  $name = htmlspecialchars($_POST["name_build"]);
  $lastname = htmlspecialchars($_POST["lastname_build"]);
  $department = utf8_encode(htmlspecialchars($_POST["department_build"]));
  $title = utf8_encode(htmlspecialchars($_POST["title_build"]));
  $dn="CN=$name OU=Users, o=Domocom, c=net";
  
  $ds = ldap_connect("192.168.1.1",389);  
  if ($ds) {
  
      ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); // IMPORTANT
      ldap_bind($ds, "administrateur@domocom.net", "password");
  
      // Prépareles données
      $cn = $info["cn"] = "$lastname $name";
      $info["sn"]="$name";
      $info["givenname"]="$lastname";
      $info["displayname"]="$lastname $name";
      $info["name"]="$lastname $name";
      $info["userprincipalname"]= "$lastname.$name@domocom.net";
      $info["samaccountname"]= "$lastname.$name";
      $info["title"]="$title";
      $info["department"]="$department";
      $info["mail"]="$lastname.$name@domocom.fr";
      $info["postalcode"]="69009";
      $info["objectClass"][0]="user";
      //$info['userPassword'] = "password";
      //$info["useraccountcontrol"]=544;
  
      $r = ldap_add($ds,"CN=$cn,OU=Users,OU=Direction,OU=Domocom-SP,DC=domocom,DC=net", $info);
      ldap_close($ds);
  } else {
      echo "unable to connect to ldap server";
  }
  ?&gt;
  </code></pre>
  
  <p>Thanks a lot.</p>
  
  <p>PS : it's fake society for my school. :p </p>