Wednesday, December 4, 2013

Fix orphan users in MS SQL Server after restore

When you restore a MS SQL Server to a different machine, you might expect orphan users.
This also happens when you detach a database and then attach it on another server.

You see the users in the Security->Users section of the sql server and also in the database itself, but you can't login with it.

The problem is, that MS SQL stores the SID along the users, and when you restore it on another MS SQL server the link between user names and SID won't match any longer.

Fixing this via GUI is unfortunally not possible, when you try to map the user it trys to create a new sql user and fails, because there already exists such a user.

Fortunally there are a few stored procedures (available since sql 2000 version) which help you fix the logins.

First, make sure that this is the problem. This will lists the orphaned users:
EXEC sp_change_users_login 'Report'
If you already have a login id and password for this user, fix it by doing:
EXEC sp_change_users_login 'Auto_Fix', 'user'
If you want to create a new login id and password for this user, fix it by doing:
EXEC sp_change_users_login 'Auto_Fix', 'user', 'login', 'password'

Tuesday, December 3, 2013

Install teamviewer 8 under linux for unattended access

Teamviewer is a great software for remote support.
 When your partner has internet access and a GUI available, you can use it to do maintenance work from anywhere in the world and via most of the devices available today. (SMartphones, tables, etc.)

With version 8 they did introduce the unattended access for linux systems too.
Unfortunally the installation routine does not always register the services correctly, so you can't access the remote system.

Fortunally there is a simple fix which works under ubuntu (and most debian based systems)

Just create a service entry yourself and set it to autostart, just as mentioned below:

cd /opt/teamviewer8/tv_bin/script
sudo cp teamviewerd.sysv /etc/init.d/
sudo chmod 755 /etc/init.d/teamviewerd.sysv
sudo update-rc.d teamviewerd.sysv defaults
With this in place you can now access the teamviewer instance on the linux system too.