Jump to content

ldap_mod_add() = "Value array must have consecutive indices 0, 1"


pakenney38

Recommended Posts

I am trying to use PHP to insert a contact into Windows Server 2003 Active Directory.

I do this:

 

<?PHP
$ldaprdn = '[email protected]';
$ldappass = 'password';
$ds = 'server.test.local';
$dn = 'dc=test,dc=local';
$ldapport = 389;
$ldapconn = ldap_connect($ds, $ldapport)
or die("Could not connect to LDAP server.");

if ($ldapconn)
{
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION,3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS,0);
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
if ($ldapbind)
{
echo "LDAP bind successful...";

$attr["cn"][0] = "ROSE TWILL";
$attr["objectclass"][0] = "top";
$attr["objectclass"][1] = "person";
$attr["objectclass"][2] = "organizationalPerson";
$attr["objectClass"][3] = "contact";
$attr["sn"][0] = "TWILL";
$attr["givenName"][0] = "ROSE";
$attr["displayName"][0] = "ROSE TWILL (2nd Server)";
$attr["mailNickname"][0] = "RTWILL";
$attr["targetAddress"][0] = "smtp:[email protected]";
$attr["mail"][0] = "[email protected]";
$attr["proxyAddresses"][0] = "smtp:[email protected]";

$result = ldap_mod_add($ldapconn, "ou=Mail Enable,ou=Test Users,ou=Test,dc=test,dc=local", $attr);
}
else
{
echo "LDAP bind failed...";
}
}
ldap_close($ldapconn);

?>

 

I get this:

 

LDAP bind successful...
Warning: ldap_mod_add() [function.ldap-mod-add]: Value array must have consecutive indices 0, 1, ... in C:\Inetpub\wwwroot\newcontact.php on line 32

 

What does this mean and what am I doing wrong? I appreciate any help on this.

 

 

Subsequently, if I try to run this:

 

<?PHP
$ldaprdn = '[email protected]';
$ldappass = 'password';
$ds = 'server.test.local';
$dn = 'dc=test,dc=local';
$ldapport = 389;
$ldapconn = ldap_connect($ds, $ldapport)
or die("Could not connect to LDAP server.");

if ($ldapconn)
{
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION,3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS,0);
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
if ($ldapbind)
{
echo "LDAP bind successful...";

$attr["cn"] = "ROSE TWILL";
$attr["objectClass"] = "contact";
$attr["sn"] = "TWILL";
$attr["givenName"] = "ROSE";
$attr["displayName"] = "ROSE TWILL (2nd Server)";
$attr["mailNickname"] = "RTWILL";
$attr["targetAddress"] = "smtp:[email protected]";
$attr["mail"] = "[email protected]";
$attr["proxyAddresses"] = "smtp:[email protected]";

$result = ldap_mod_add($ldapconn, "ou=Mail Enable,ou=Test Users,ou=Test,dc=test,dc=local", $attr);
}
else
{
echo "LDAP bind failed...";
}
}
ldap_close($ldapconn);

?>

 

I get back:

 

LDAP bind successful...
Warning: ldap_mod_add() [function:ldap-mod-add]: Modify: Server is unwilling to perform in C:\Intepub\wwwroot\newcontact.php on line 29

 

What so now Active Directory is just telling me "no" ?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.