Exemple #1
0
    /// <summary>
    /// Unlicense the user
    /// </summary>
    /// <param name="unexpectedUser"></param>
    /// <param name="siteSignIn"></param>
    /// <param name="workingList_allKnownUsers"></param>
    private void Execute_UpdateUnexpectedUsersProvisioning_SingleUser_WithBehavior_Unlicense(
        SiteUser unexpectedUser,
        TableauServerSignIn siteSignIn,
        WorkingListSiteUsers workingList_allKnownUsers)
    {
        //If the user is already unlicensed, then there is nothing that needs to be done
        if (unexpectedUser.SiteRoleParsed == SiteUserRole.Unlicensed)
        {
            return;
        }

        _statusLogs.AddStatus("Unlicense unexpected user: "******"existing/removed",
                unexpectedUser.SiteRole + "->" + userUpdated.SiteRole);

            workingList_allKnownUsers.ReplaceUser(userUpdated);
            return;
        }
        else
        {
            CSVRecord_ErrorUpdatingUser(unexpectedUser.Name, unexpectedUser.SiteRole, unexpectedUser.SiteAuthentication, "Error unlicensing user (913-215)");
            return;
        }
    }
    /// <summary>
    /// Update the unexpected user based on the specified behavior
    /// </summary>
    /// <param name="unexpectedUser"></param>
    /// <param name="siteSignIn"></param>
    /// <param name="behavior"></param>
    private void Execute_UpdateUnexpectedUsersProvisioning_SingleUser_WithBehavior(SiteUser unexpectedUser, TableauServerSignIn siteSignIn, ProvisionUserInstructions.UnexpectedUserAction behavior)
    {
        switch (behavior)
        {
        case ProvisionUserInstructions.UnexpectedUserAction.Report:
            _statusLogs.AddStatus("No action: Keep unexpected user unaltered. User: "******"Per provisioning instructions, unknown existing user left unaltered");
                 */
                CSVRecord_UserModified(
                    unexpectedUser.Name,
                    unexpectedUser.SiteRole,
                    unexpectedUser.SiteAuthentication,
                    "SIMULATED existing/removed",
                    unexpectedUser.SiteRole + "->" + "Unlicensed");
                return;
            }

            return;

        case ProvisionUserInstructions.UnexpectedUserAction.Unlicense:
            //If the user is already unlicensed, then there is nothing that needs to be done
            if (unexpectedUser.SiteRoleParsed == SiteUserRole.Unlicensed)
            {
                return;
            }

            _statusLogs.AddStatus("Unlicense unexpected user: "******"existing/removed",
                unexpectedUser.SiteRole + "->" + userUpdated.SiteRole);
            return;

        default:
            IwsDiagnostics.Assert(false, "811-1130: Internal error. Unknown provisioning behavior for user " + unexpectedUser.ToString());
            _statusLogs.AddError("811-1130: Internal error. Unknown provisioning behavior for user " + unexpectedUser.ToString());
            return;
        }
    }
Exemple #3
0
    /// <summary>
    /// The MODIDFY-Existing user path for user provisioning
    /// </summary>
    /// <param name="siteSignIn"></param>
    /// <param name="userToProvision"></param>
    /// <param name="missingUserAction"></param>
    private void Execute_ProvisionUsers_SingleUser_ModifyUser(TableauServerSignIn siteSignIn, ProvisioningUser userToProvision, SiteUser existingUser)
    {
        ProvisionUserInstructions.ExistingUserAction existingUserAction;
        switch (existingUser.SiteAuthenticationParsed)
        {
        case SiteUserAuth.Default:
            existingUserAction = _provisionInstructions.ActionForExistingDefaultAuthUsers;
            break;

        case SiteUserAuth.SAML:
            existingUserAction = _provisionInstructions.ActionForExistingSamlUsers;
            break;

        case SiteUserAuth.OpenID:
            existingUserAction = _provisionInstructions.ActionForExistingOpenIdUsers;
            break;

        default:
            IwsDiagnostics.Assert(false, "814-1234: Unknown user auth type");
            throw new Exception("814-1234: Unknown user auth type");
        }

        switch (existingUserAction)
        {
        //Modify the existing user
        case ProvisionUserInstructions.ExistingUserAction.Modify:
            _statusLogs.AddStatus("Update user: User exists but role or auth differs. Update: " + userToProvision.UserName);

            var updateUser = new SendUpdateUser(
                siteSignIn,
                existingUser.Id,
                userToProvision.UserRole,
                userToProvision.UserAuthenticationParsed != existingUser.SiteAuthenticationParsed,     //We only want to update the user role if it is NOT what we expect it to be
                userToProvision.UserAuthenticationParsed);

            var userUpdated = updateUser.ExecuteRequest();

            if (userUpdated != null)
            {
                //-------------------------------------------------------------------------------
                //Record the action in an output file
                //-------------------------------------------------------------------------------
                CSVRecord_UserModified(
                    userToProvision.UserName,
                    userToProvision.UserRole,
                    userToProvision.UserAuthentication,
                    "existing/modified",
                    existingUser.SiteRole + "->" + userUpdated.SiteRole + ", " + existingUser.SiteAuthentication + "->" + userUpdated.SiteAuthentication);
                return;
            }
            else
            {
                //Error case, the user was not updated
                CSVRecord_ErrorUpdatingUser(userToProvision.UserName, userToProvision.UserRole, userToProvision.UserAuthentication, "Error updating user (913-212)");
                return;
            }

        //Don't modify, but report
        case ProvisionUserInstructions.ExistingUserAction.Report:
            CSVRecord_UserModified(
                userToProvision.UserName,
                userToProvision.UserRole,
                userToProvision.UserAuthentication,
                "SIMULATED existing/modified",
                existingUser.SiteRole + "->" + userToProvision.UserRole + ", " + existingUser.SiteAuthentication + "->" + userToProvision.UserAuthentication);
            return;

        default:
            IwsDiagnostics.Assert(false, "814-1237: Internal error. Unknown modify user action");
            throw new Exception("814-1237: Internal error. Unknown modify user action");
        }
    }
    /// <summary>
    /// The MODIDFY-Existing user path for user provisioning
    /// </summary>
    /// <param name="siteSignIn"></param>
    /// <param name="userToProvision"></param>
    /// <param name="missingUserAction"></param>
    private void Execute_ProvisionUsers_SingleUser_ModifyUser(TableauServerSignIn siteSignIn, ProvisioningUser userToProvision, SiteUser existingUser)
    {
        ProvisionUserInstructions.ExistingUserAction existingUserAction;
        switch (existingUser.SiteAuthenticationParsed)
        {
        case SiteUserAuth.Default:
            existingUserAction = _provisionInstructions.ActionForExistingDefaultAuthUsers;
            break;

        case SiteUserAuth.SAML:
            existingUserAction = _provisionInstructions.ActionForExistingSamlUsers;
            break;

        default:
            IwsDiagnostics.Assert(false, "814-1234: Unknown user auth type");
            throw new Exception("814-1234: Unknown user auth type");
        }

        switch (existingUserAction)
        {
        //Modify the existing user
        case ProvisionUserInstructions.ExistingUserAction.Modify:
            _statusLogs.AddStatus("Update user: User exists but role or auth differs. Update: " + userToProvision.UserName);
            var updateUser = new SendUpdateUser(
                siteSignIn.ServerUrls,
                siteSignIn,
                existingUser.Id,
                userToProvision.UserRole,
                userToProvision.UserAuthenticationParsed);

            var userUpdated = updateUser.ExecuteRequest();

            //-------------------------------------------------------------------------------
            //Record the action in an output file
            //-------------------------------------------------------------------------------
            CSVRecord_UserModified(
                userToProvision.UserName,
                userToProvision.UserRole,
                userToProvision.UserAuthentication,
                "existing/modified",
                existingUser.SiteRole + "->" + userUpdated.SiteRole + ", " + existingUser.SiteAuthentication + "->" + userUpdated.SiteAuthentication);
            return;

        //Don't modify, but report
        case ProvisionUserInstructions.ExistingUserAction.Report:
            //-------------------------------------------------------------------------------
            //Record the action in an output file
            //-------------------------------------------------------------------------------

            /*                CSVRecord_Warning(
             *                  userToProvision.UserName,
             *                  userToProvision.UserRole,
             *                  userToProvision.UserAuthentication,
             *                  "Modify user: Per provisioning instructions, existing user left unaltered. " + existingUser.SiteRole + "->" + userToProvision.UserRole + ", " + existingUser.SiteAuthentication + "->" + userToProvision.UserAuthentication);
             */
            CSVRecord_UserModified(
                userToProvision.UserName,
                userToProvision.UserRole,
                userToProvision.UserAuthentication,
                "SIMULATED existing/modified",
                existingUser.SiteRole + "->" + userToProvision.UserRole + ", " + existingUser.SiteAuthentication + "->" + userToProvision.UserAuthentication);
            return;

        default:
            IwsDiagnostics.Assert(false, "814-1237: Internal error. Unknown modify user action");
            throw new Exception("814-1237: Internal error. Unknown modify user action");
        }
    }