Open heisenbol opened 9 years ago
forgot to say that I am using the latest development code (upcoming 5.0)
I was running into the same problem.
When we use find method it finds the first user matches, but we need specific user.
You may need to find the user by doing explicit search that find the unique user you want.
In my case samaccountnumber field is unique username field so I am running search like this and this provides me the unique user that I need to change password for.
$adUser = $secureAdldap->search() ->where('samaccountname', '=', $username) ->select([ 'cn', 'memberof', 'samaccountname', 'mail', 'telephoneNumber', 'pwdlastset', 'accountexpires', 'useraccountcontrol' ]) ->first();
I've tried to change a user's password using $ad->user()->changePassword($userName, $newPassword, $oldPassword)
which usually works as expected. I use an account_suffix in my adLdap configuration.
But for a specific user, I always got a WrongPasswordException exception.
After some search, it turns out that within changePassword(), it gets the userDN with $userDn = $this->dn($username);
The dn function, calls $info = $this->find($name);
with the given username, which in turns does an ldap search and returns the first matched entry. In my case, this first entry was another user (who's name starts with the given username).
If, while initializing adLdap, I remove my account_suffix parameter, and use as username the complete email address, it works as expected.