Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Username Update Broken when using GUID FK #760

Closed
benyanke opened this issue Jul 16, 2019 · 3 comments

Comments

@benyanke
Copy link

commented Jul 16, 2019

  • Laravel Version: 5.5.45
  • Adldap2-Laravel Version: v3.0.9
  • PHP Version: 7.2
  • LDAP Type: ActiveDirectory

Description:

We are using the user AD GUID as the primary key. However, when a user changes their username, a SQL error is thrown about trying to create a new account instead of updating the existing one.

I need a way to tell ADLDAP2-Laravel what I want they key attribute to be, so it can do a lookup even with a changed username.

Steps To Reproduce:

  • Import user
  • Change AD username
  • sql error thrown in logs. Redacted data in [brackets]
[2019-07-16 10:17:38] production.ERROR: Unable to import user [name] SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '[guid]' for key 'PRIMARY' (SQL: insert into `users` (`email`, `name`, `username`, `phone`, `department`, `distinguishedname`, `guid`, `[private attribute name]`, `[private attribute name]`, `[private attribute name]`, `nav_username`, `emailtopia_address`, `full_ad_username`, `password`, `updated_at`, `created_at`) values ([user]@[domain]com, [name], [username], [phone], [dept], [dn], [hash], , , , , , , [hash], 2019-07-16 10:17:38, 2019-07-16 10:17:38))  
@stevebauman

This comment has been minimized.

Copy link
Member

commented Jul 16, 2019

Hi @benyanke,

This is actually a feature that was added in v6.0.

However, to do this in v3.0, you would have to extend the DatabaseUserProvider as well as the Importer.

For the DatabaseUserProvider you will need to override the retrieveByCredentials() method and for the Importer, you will need to override the findByCredentials() method.

I can't give you example code since this is implementation dependent and v6.0 supports this feature.

Hope this helps!

@benyanke

This comment has been minimized.

Copy link
Author

commented Jul 16, 2019

Thank you! I'll give this a try.

@stevebauman

This comment has been minimized.

Copy link
Member

commented Jul 16, 2019

No problem! Let me know if you run into any issues and I'll do my best to help you out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.