Skip to content

[Bug] Changed email not being updated #40

Description

@2PintChristianN

Summary

User in AD has different email from what is in TV, the email in TV is an alias (previous main email) of the user.
This especially becomes an issue with SSO login, where TV says the account doesn't exist.

Expected Behavior

The changed email in AD should be updated in TV

Steps To Reproduce

  1. Sync user from AD to TV
  2. Change email in AD
  3. Sync
  4. Email in TV was not updated and is still the old value

Fix

index 2c0342a..22807f7 100644
--- a/TeamViewerADConnector/Internal/Sync.ps1
+++ b/TeamViewerADConnector/Internal/Sync.ps1
@@ -41,6 +41,9 @@ function ConvertTo-SyncUpdateUserChangeset($userTV, $userAD) {
     if ($userAD.name -ne $userTV.name) {
         $changeset.name = $userAD.name
     }
+    if ($userAD.email -ne $userTV.email) {
+        $changeset.email = $userAD.email
+    }
     if ($userAD.IsEnabled -ne $userTV.active) {
         $changeset.active = $userAD.IsEnabled
     }
@@ -57,6 +60,9 @@ function Format-SyncUpdateUserChangeset {
         if ($changeset.name) {
             $message += "Changing name to '$($changeset.name)'. "
         }
+        if ($changeset.email) {
+            $message += "Changing email to '$($changeset.email)'. "
+        }
         if ($changeset.active) {
             $message += "Changing account status to 'active'. "
         }
@@ -181,7 +181,7 @@ function Invoke-SyncUser($syncContext, $configuration, $progressHandler) {
     ForEach ($userAd in $syncContext.UsersActiveDirectory) {
         $userTv = $userAd | Resolve-TeamViewerAccount $syncContext $configuration
 
-        if ($userTv -and $userTv.active -and $userTv.name -eq $userAd.name) {
+        if ($userTv -and $userTv.active -and $userTv.name -eq $userAd.name -and $userTv.email -eq $userAd.email) {
             Write-SyncLog "No changes for user $($userAd.email). Skipping."
             $statistics.NotChanged++
         }

But even with this, the email doesn't change in TV, even tho the email is in the REST PUT request to update the user

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions