Remove associated email from user

  • 1
  • Problem
  • Updated 10 months ago

I'm trying to remove/unassociate an email from a user, by updating the user and setting the "Emails" to only contain the one correct email address for the user, rather than two (one correct and one old/incorrect).

I can see the two emails using the following:

Send-SfRequest -Client $Client -Method GET -Uri "https://$($ApiHost)/sf/v3/Users($($UserId))" | Select-Object -Property Emails

Result:

Emails
------
{correct@example.com, incorrect@example.org}

I attempted to remove the incorrect email by using the following:

$UpdDetails = @{
    'Emails' = @(
        'correct@example.com'
    )
}
Send-SfRequest -Client $Client -Method PATCH -Uri "https://$($ApiHost)/sf/v3/Users($($UserId))" -BodyText $($UpdDetails | ConvertTo-Json)

Result:

Send-SfRequest : NotFound: Email: You cannot add this email address because it is already associated with you.
+ Send-SfRequest -Client $Client -Method PATCH -Uri "$($ApiHost ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Send-SfRequest], Exception
    + FullyQualifiedErrorId : NotFound,ShareFile.Api.Powershell.SendSfRequest

How do I remove the associated email that is incorrect?

Background...

The correct and incorrect email is usually a new client email address and an old (SSO) employee email address. Because the user is no longer an employee, the SSO login is automatically disabled, which in turn downgrades the user to a client (as they should be). But they are then experiencing problems logging in, because ShareFile can't seem to handle a scenario like this. Other employees cannot share content with them because they somehow don't properly exist in the Web UI, even though they exist when looking through API. Attempting to create the user as a client ofcourse fails, because the email address that is attempting to be created already exists in the system. Deleting the account and re-inviting the user again, as a client, resolves the issue but adds the unnecessary overhead of re-adding that user to the various folders they had access to prior to being deleted.

Photo of briped

briped

  • 10 Posts
  • 0 Reply Likes

Posted 10 months ago

  • 1
Photo of Michael Berrier

Michael Berrier, Official Rep

  • 123 Posts
  • 24 Reply Likes
briped,

Sorry for the delayed reply. You should be able to delete the email address for a user by using the Delete Email Address endpoint:

/sf/v3/Users/DeleteEmailAddress?email=incorrect%40example.org

See the Users API documentation for detail:
http://api.sharefile.com/rest/docs/resource.aspx?name=Users

Note that you can't delete the primary email address for a user, so if the problematic email is currently the primary, you will have to make an additional call first to set a different primary. E.g.,

sf/v3/Users/MakePrimary?email=correct%40example.org


Michael Berrier
ShareFile Engineering