1

In a SharePoint 2013 OnPrem environment, I have an add-in that needs to get the email address of the current user, using the following code:

var clientContext = new SP.ClientContext();
user = clientContext.get_web().get_currentUser();
var email = user.get_email();

We recently discovered that new users were missing email addresses. I went to Central admin and looked up the user, but the email was registered fine.

Then I opened up PowerShell and used Get-SPUser to find the user and view the details. To my surprise, the email address was not there.

I updated the email address using Set-SPUser and everything was working again. But this workaround requires a manual step for every New user in SharePoint.

Why isn't the email address reflected in the result of Get-SPUser, when it shows up correctly in the user profile administration in Central admin..?

1
  • Also, I noted that the user profile sync service is stopped. Might this have anything to do With it? Commented Feb 1, 2016 at 8:36

1 Answer 1

0

Please perform the following steps:

stsadm -o sync -listolddatabases 0

If that shows any databases > 0 days, then run:

stsadm -o sync -deleteolddatabases 0

This clears the UPA -> Content Database synchronization information. The next time the User Profile Service Application - User Profile to SharePoint Full Synchronization (job name varies based on the name of your UPA Service App), this information should be populated correctly for all users.

2
  • Thanks for Your suggestion. I ran the first command, and one database showed up. I am a bit uncertain as to whether I should run the deleteolddatabases command since I don't fully understand what it does, and what is the consequences if it doesn't work out as expected. Could you please tell me a little bit more about what is the risk of doing this? Commented Feb 1, 2016 at 8:35
  • The deleteolddatabases component of the command performs the same operation as the listolddatabases parameter, except it deletes old records corresponding to these databases. It does not delete the databases themselves. Andy Commented Feb 1, 2016 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.