ldap_add - Server is unwilling to peform

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello-
I am trying to add create a user account with the ldap_add function.  However I 
get the error below when it is invoked.  Does anyone have ideas what may be 
causing this error?  What I can look into?  Anything would be helpful.

Warning: ldap_add() [function.ldap-add]: Add: Server is unwilling to perform 
in C:\xampp\htdocs\Infrastructure\al_ldap.php on line 354

Line 354 is the actual call to ldap_add().  

Thanks-
Chuck

function al_ldap_add_user($Fname,$Lname,$Aname,$UPname,$Hdir,$MemberOf,$Admin)
{
session_start();
$info = array();
$user = $_SESSION['username']."@dh2.pub.com";
$password = $_SESSION['password'];
$iv = $_SESSION['iv'];//for decryption
$key = $_SESSION['key'];//for decryption
//$dn_ending = ",OU=Lab Associates,OU=Accounts,DC=DH2,DC=pub,DC=com";
$dn_ending = ",OU=Testing,OU=Accounts,DC=DH2,DC=pub,DC=com";
$obj_cat = "CN=Person,CN=Schema,CN=Configuration,DC=DH2,DC=pub,DC=com";
$decryptedpw = al_decrypt($password,$iv,$key);//call decryption function to get 
the plain text password
$FullName = $Fname .  " " . $Lname;
$DN = "CN=" . $FullName . $dn_ending;
$ds=ldap_connect($_SESSION['ldap_addr']);  // must be a valid LDAP server!
if ($ds) 
{ 
$r=ldap_bind($ds,$user,$decryptedpw);     
// prepare data
$info["sAMAccountName"] = $Aname;
$info["sAMAccountType"] = "805306368";
$info["cn"] = $FullName;
$info["displayName"] = $FullName;
$info["name"] = $FullName;
$info["sn"] = $Lname;
$info["givenName"] = $Fname;
$info["userPrincipalName"] = $UPname;
$info["homeDirectory"] = $Hdir;
$info["homeDrive"] = "U:";
$info["objectCategory"] = $obj_cat;
$info["objectClass"][0] = "top";
$info["objectClass"][1] = "person";
$info["objectClass"][2] = "organizationalPerson";
$info["objectClass"][3] = "user";
if( $Admin)
$info["adminCount"] = 1;
$N = count($MemberOf);
for($i=0; $i < $N; $i++)
{
  $info["memberOf"][$i] = str_replace("'","",$MemberOf[$i]);
}

// add data to directory
var_dump($info);
$ad = ldap_add($ds, $DN, $info);
if($ad)
return true;
else
{
echo "<h4>Unable to create user</h4>";
return false;
}
} else {
echo "<h4>Unable to connect to LDAP server</h4>";
}

}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux