LDAP Question

General discussion on Zend Core for IBM System i
Post Reply
fasanom
Posts: 2
Joined: Fri Dec 18, 2009 1:19 pm

LDAP Question

Post by fasanom » Fri Dec 18, 2009 1:29 pm

Everyone,

Thanks in advance for any replies - I appreciate it. I am trying to update a field in existing Active Directory ( employeeid field ) with information coming from our AS400 payroll files. I am able to read successfully from AD and have verified that the account i am using for ldap has admin rights. Here is my code - if anyone can shed any light on this I would be eternally grateful.

Thanks!

LDAP UPDATE CODE
-----------------------

$ad_server = 'acme.corptest.com';
$ad_user = 'username1';
$ad_pass = 'Password1';
$ad_port = '389';

$ad_connect = ldap_connect($ad_server, $ad_port);
$option1 = ldap_set_option($ad_connect, LDAP_OPT_PROTOCOL_VERSION, 3) or die ("Could not set ldap protocol");
$option2 = ldap_set_option($ad_connect, LDAP_OPT_REFERRALS, 0) or die ("Could not set option referrals");

$ad_base_dn = 'DC=corptest,DC=com';
$ad_bind = ldap_bind($ad_connect, $ad_user, $ad_pass);
if ($ad_bind)
{
echo "LDAP bind successful...";
}
else
{
echo "LDAP bind failed...";
}

$search1 = array();
$filter = '(samaccountname=krbtgt*)';
$result = ldap_search($ad_connect, $ad_base_dn, $filter, $search1, '', 0 );
$entries = ldap_get_entries($ad_connect,$result);

for ($i=0; $i<$entries["count"]; $i++)
{
$new_entries[$i]['employeeid'][0] = 3512;
$ldap_replace = ldap_mod_replace($ad_connect, $ad_base_dn, $entries);

var_dump($ldap_replace);
var_dump(ldap_error($ad_connect));
var_dump(ldap_errno($ad_connect));

}

Here are the results I am getting:

The error on ldap_replace = ERROR IS line 153 - ldap_mod_replace() [<a href='function.ldap-mod-replace'>function.ldap-od-replace</a>]: Unknown attribute in the data
var_dump($ldap_replace) = bool(false)
var_dump(ldap_error($ad_connect)) = string(7) "Success"
var_dump(ldap_errno($ad_connect)) = int(0)

fasanom
Posts: 2
Joined: Fri Dec 18, 2009 1:19 pm

Re: LDAP Question

Post by fasanom » Fri Dec 18, 2009 1:30 pm

Sorry I just realized my typo - the ldap_replace is for $new_entries - not $entries

Thanks!

Post Reply