pakenney38 Posted April 4, 2008 Share Posted April 4, 2008 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. Link to comment https://forums.phpfreaks.com/topic/99590-ldap_mod_add-value-array-must-have-consecutive-indices-0-1/ Share on other sites More sharing options...
pakenney38 Posted April 4, 2008 Author Share Posted April 4, 2008 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" ? Link to comment https://forums.phpfreaks.com/topic/99590-ldap_mod_add-value-array-must-have-consecutive-indices-0-1/#findComment-509499 Share on other sites More sharing options...
pakenney38 Posted April 4, 2008 Author Share Posted April 4, 2008 Apparently I got some incorrect documentation. The command I am supposed to be using is ldap_add(), not ldap_mod_add(). Link to comment https://forums.phpfreaks.com/topic/99590-ldap_mod_add-value-array-must-have-consecutive-indices-0-1/#findComment-509516 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.