How to restore (undelete) a user which has been soft deleted

Version 26

    Verified Product Versions

    LANDESK Service Desk 7.6LANDESK Service Desk 7.7.xLANDESK Service Desk 7.8.xLANDESK Service Desk 2016.xLANDESK Asset Central 2016.xLANDESK Service Desk 2017.x

    Environment:

    Service Desk 7.4 and newer

     

    Review Date:

    02.10.2014

     

              How do Users work in Service Desk?

     

    A user in Service Desk include 'Analyst', 'Contact', 'Account Manager', 'End User' and 'System User'

    When you create a user in Service Desk the user will be created in the user tables in the database. It will also be specified which type of user it is, ie: 'Analyst', 'Contact', 'Account Manager', 'End User' or 'System User'

    When users are deleted the users information is retrained in the database so that anything this user is linked to can remain working on the system. This is called soft delete and means that the user still exist in the database, but can't be seen from the front end. This user will not be able to log in to the system and cannot be selected in any processes or queries.

     

    If you were to try and create a user with the same name as a user that already exist in the database, you will get an error message when saving the user.

     

    In 7.7.2 and previous versions:

     

    "Cannot insert duplicate key row in object 'dbo.tps_user' with unique index 'index$tps_user$name"

     

    deleterror.jpg

     

    In 7.7.3 and newer versions:

    You will get a different error message depending if the username you are trying to create exist as an active user or if the user is soft deleted.

     

    "Cannot create a record with name 'XXX'. This is already in use by another record"

    "Cannot create a record with name 'XXX. A softdeleted record already exists. This record should be restored or renamed"

    duplicate_error1.pngduplicate_error2.png

     

     

     

     

              How to restore a soft deleted user:


     



    7.7.3 and newer:

    This can be done from within Console. Note that this is not a WebAccess feature.

    Create a new Query in Query and Report Designer on your User Object.

    Add the relevant attribute as columns and make sure to add the "Soft Deleted" attribute

    On the General page, tick the "Include soft deleted records" tick box

     

    query.png

    In the result you will now be able to see all users, no matter if they are soft deleted or not. The "Soft Deletion" column will let you know the status of the user.

    query_result.png

    If you wish to restore a user. Right click on the relevant user and choose "Restore"

    restore.png

     

     

    ----------------------------------------------------------------------------------------------------------------------------------------------------

     

     

    7.7.2 and previous:

    Soft deleted users can be displayed by creating a query in Service Desk. If the user as been previously deleted a new account can be created or the soft deleted account can be restored using the scripts below:

     

    SQL Version

    Please read the advice at the bottom of this article before applying the script. The tps_name value in the scripts has to be updated to the required user by replacing the usersloginid text. For example if I would like to restore the Guest account the modified line in the sql script would read:

     

    SET @USERS_LOGIN = 'Guest'

     

    -- Please replace the string usersloginid with the login id of the user being restored  DECLARE @USERS_LOGIN VARCHAR(64) SET @USERS_LOGIN = 'usersloginid'    UPDATE tps_user SET tps_deleted = '0' WHERE tps_name = @USERS_LOGIN; UPDATE tps_password SET tps_deleted = '0' WHERE tps_guid = (SELECT tps_password_id FROM tps_user WHERE tps_name = @USERS_LOGIN);

     

    If the update is a success two rows will be returned as updated.

     

    Oracle Version

    Please read the advice at the bottom of this article before applying the script. The line starting with the define statement has be updated for the required user. An updated line for the Guest account would look as follows:

     

    DEFINE USERS_LOGIN = "Guest"

     

    Please remember be aware a case sensitivity when using Oracle.

     

     -- Please replace the string usersloginid with the login id of the user being restored  SET VERIFY OFF DEFINE USERS_LOGIN = "usersloginid"   UPDATE tps_user SET tps_deleted = '0' WHERE tps_name = '&&USERS_LOGIN'; UPDATE tps_password SET tps_deleted = '0' WHERE tps_guid = (SELECT tps_password_id FROM tps_user WHERE tps_name = '&USERS_LOGIN');  COMMIT;   

     

    If the update is a success two rows will be returned as updated.

     

    Disclaimer

    This should be run by your database administrator and tested against a test copy of your database before applying live. When you apply to the live database, please ensure that no-one else is logged in and that a backup of the database has been taken. In the event of any problems you should restore from the backup copy.

     

    ----------------------------------------------------------------------------------------------------------------------------------------------------

     


    PLEASE ALSO NOTE:

    If you have followed the Article about how to remove users from LANDesk Service Desk when deleted in AD and need to restore a soft deleted analyst you will need to make sure to change the delete attribute used for the AD import as well, otherwise the trigger applied to the tps_user table will fire and soft delete the user again.

    How to configure Service Desk to clear out deleted AD users