Elevating a User to Administrator from Outside of the UI

Version 1

    Problem

    On the off chance you find yourself with an Xtraction installation where no one seems to have administrator access, you can't grant someone Administrator access because you need to BE an administrator change user accounts.

     

    This could happen if a consultant installs Xtraction, making themselves admin, and then leaving. Or, the only Xtraction admin leaves the company without promoting anyone else, and now you are stuck. In an ideal world, these scenarios would never happen, but this isn't an ideal world.

     

    So, the problem is, how do you grant someone Xtraction Administrator access if no one else has Administrator access that could grant the role for them?

    This solution requires Xtraction to restart. While this is a momentary outage and may not affect anyone, there is the possibility for users to receive error messages and/or possibly lose unsaved work. While only momentary, it is considered an outage as the application stops and restarts.

     

    Solution

    The solution involves inserting a single record in the Xtraction database. Below are the steps for inserting that record:

     

    Backup the database

    As a precaution, back up the Xtraction database prior to making this change.

     

    Determine the UserId

    Use the following query to identify the UserId of the account to elevate to Administrator. Using SQL Server Management Studio, or any other SQL querying tool, to run the query.

     

    Replace the "xxx" with part of the user name as it appears in the bottom right corner of Xtraction when the user logs in. 

     

    select userid, username from [user]

    where username like '%xxx%'

     

    From the result set, note the UserId of the relevant user record for use in the following steps.

     

    Determine the User's Current Roles

    Use the following query to determine what role IDs already exist for the user with the UserId identified in the previous query. Replace the "nnn" in the query with that UserId.

     

    select * from userrole

    where userid = nnn

     

    If the result set includes a record with a RoleId of 1 for the given UserId, then that user already has the Administrator role, and nothing more should be required.

     

    Insert the Record

    Assuming the previous step did not reveal an existing record with a RoleId of 1, you need to add such a record using the following query. Replace the "nnn" in the query with that UserId.

     

    insert into userrole (userid, roleid)

    values (nnn, 1)

     

    This should have added the necessary record into the Xtraction database to grant Administrator rights to the specified user, after the final step of restarting Xtraction.

     

    Restart Xtraction

    From IIS Manager, stop/restart the Xtraction application pool to restart Xtraction.

     

    After completing the above steps, the specified user should now be able to log into Xtraction with Administrator privileges.  If the user is already logged into Xtraction, they will need to log out and then log back in before they will see the change.