Categories
SQL

SQL : Database ‘Database_Name’ already exists

SQL : Database ‘Database_Name’ already exists

When re-attaching a database I received an error “Database ‘Database_Name’ already exists.” There were no duplicate name databases with the instance, so this was incorrect.

After running the following SQL I found that the database was still ‘known:’
select name from sys.databases

To resolve the issue, execute the command below, changingt he database name:
DROP database ‘Database_Name’

Categories
Exchange Server 2007

Exchange 2007 : Convert Linked Mailbox to User Mailbox

Exchange 2007 and 2010 : Convert Linked Mailbox to User Mailbox

During a migration cleanup I came across several user mailboxes that were ‘Linked’ and not ‘User’ mailboxes.

(In a non resource forest model) this is usually caused by;

  1. Associated External Account Permission
  2. Attribute ‘msExchMasterAccountSid’ is not null  / ‘msExchRecipientTypeDetails’ set to ‘2’ (both are usually as a result of 1)

Associated External Account Permission

Executing the following command did reveal that there was a permission for an External Account (despite the account being in the same domain as the mailbox):

{code lang:xml title:”Show Mailbox ExternalAccount Permission” lines:true hidden:false}$mbx = Get-Mailbox “alias”
$mbx | Get-MailboxPermission | ? {$_.accessrights -like “*ExternalAccount*”} {/code}

Attribute ‘msExchMasterAccountSid’ is not null  / ‘msExchRecipientTypeDetails’ set to ‘2’

Using adsiedit I confirmed that the ‘msExchRecipientTypeDetails’ attribute was set to 2 (Linked) and not 1 (User), and that the ‘msExchMasterAccountSid’ attribute was not null (not default!).

Correcting the Issue

Executing the following script in the Exchange Management Shell will change ALL mailboxes from Linked to user, modify the mailbox alias as required. Be sure this is what you want to do! In a Resource Forest scenario this would be undesirable to say the least!

{code lang:css title:”Cleanup Script” lines:true hidden:false}# Identify all LINKED mailboxes
$linkedmbx = Get-Mailbox | ? {$_.islinked -eq $true}

foreach ($mbx in $linkedmbx)
{

# Find and Remove Associated External Account Permission
$extacc = $mbx | Get-MailboxPermission | ? {$_.accessrights -like “*ExternalAccount*”}
$extacc.User
Remove-MailboxPermission -Identity $mbx.DistinguishedName -User $extacc.User -AccessRights ExternalAccount

# Change the Mailbox Type and Null the msExchMasterAccountSid attribute for the user
$LDAPPath = “LDAP://” + $mbx.DistinguishedName
$LDAPPath | fl

$user = [ADSI]”$LDAPPath”
$user | fl

$user.put(“msExchRecipientTypeDetails”,1)
$user.putex(1,”msExchMasterAccountSid”,$null)
$user.setinfo(){/code}

Categories
Windows Server 2003

HP DataProtector : Cannot obtain Cell Manager host

HP DataProtector : Cannot obtain Cell Manager host

Came across this one today, the below error suddenly started to appear on a SQL backup that was working one day and stopped the next without any change or modification to the SQL server or Cell Manager:

Normal 0
[Critical] From: [email protected] "OSCDB"  Time: 2/10/2011 2:40:04 AM
Cannot obtain Cell Manager host. Check the /etc/opt/omni/client/cell_server file and permissions of /etc/resolv.conf file.

On investigation I found that the CellServer registry key, listed below, was infact empty. Upon re-entering the CellServer (Cell Manager) name the backup started to work again:

HKEY_LOCAL_MACHINE\SOFTWARE\Hewlett-Packard\OpenView\OmniBackII\Site\CellServer
Categories
SQL

SQL : SQL Server Management Studio Alternate Domain Credentials

SQL : SQL Server Management Studio Alternate Domain Credentials

Whilst working in a split domain, lets say Domain A and Domain B, environment we had a request for a user from Domain A to login using SQL Server Management Studio (SSMS) using Windows Credentials (Domain Account) to connect to a SQL instance using credentials from Domain B. The domains in this environment did not trust each other, they were isolated environments with only DNS stub-zones/secondary zones in place to ensure connetcivity to resources.

SSMS will not allow you to enter alternate Windows Credentials when connecting using Windows Authentication. It is however possible to achieve this using RunAs in the following way:

RUNAS /netonly /user:DOMAINB\user “C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe”

You can even set this as a shortcut which will then prompt for the supplied username’s password and then exeute SSMS.

Categories
Windows 7

Windows : NetLogon Service Missing

Windows : NetLogon Service Missing

Encountered a machine today where the user was unable to connect to network printers. On further investiagtion users without cached credentials were unable to logon to the machine and received an error regarding the NetLogon service not running. After checking the netlogon service, it was infact missing!

To resolve this simply install ‘Client for Microsoft Networks’ from the LAN/Wireless network adapter configuration and reboot.

Categories
SQL

SQL : Unlock Account

SQL : Unlock Account

Use the following SQL to unlock an account in SQL 2005/2008, simply change the account name in square brackets:

ALTER LOGIN [sa] WITH CHECK_POLICY = OFF;
ALTER LOGIN [sa] WITH CHECK_POLICY = ON;

 

Categories
Windows Server 2003

Cluster: Generic Script – Rouge Process Cleanup/Terminate

Cluster: Generic Script –  Rouge Process Cleanup/Terminate

I came across an interesting issue whilst clustering a CODA application server on a Windows Server 2003 Enterprise Microsoft Cluster. CODA spawns multiple processes after service startup, these processes are not services and as a result the cluster is not aware of them. When the CODA services are stopped theadditional processes are not always cleaned up. If the services are started again they will fail with a bind error.

I created a Cluster Generic Script to cleanup ‘rogue’ processes on resource group stop and start. Initially the script below contained a process.terminate() function, however this does not work for SYSTEM owned process. I therefore explored using taskkill.exe which is built into Windows, this means that no additional components are required to get this script working.

‘Chris’ CODA Fix Cluster Script – Created 14/01/2011

Dim WshShell, oExec, oLooksAlive, oIsAlive, oWait, objWMIService, colProcess, objProcess, strComputer, objShell
Set WshShell = CreateObject(“WScript.Shell”)

processName = “oasasv.exe”

‘On Error Resume Next

Function Online( )
    Resource.LogInformation “Entering Online”
    On Error Resume Next
   
    If CheckProcess > 0 Then KillProcess
   
    If CheckProcess > 0 Then
        Resource.LogInformation “Rougue ‘” & processName & “‘ process still present, FAILED to kill…”
        Online = False
    Else
        Online = True
    End If
       
    If Err.Number > 0 Then
      Resource.LogInformation Err.Details
      Resource.LogInformation oExec.StdErr.ReadAll
    End If   
End Function

Function Offline( )
    Resource.LogInformation “Entering Offline”
   
    If CheckProcess > 0 Then KillProcess
   
    If Err.Number > 0 Then
      Resource.LogInformation Err.Details
      Resource.LogInformation oExec.StdErr.ReadAll
    End If
     
    Offline = True
End Function

Function LooksAlive( )
     Resource.LogInformation “Entering LooksAlive”
     LooksAlive = True
End Function

Function IsAlive( )
     Resource.LogInformation “Entering IsAlive”
     IsAlive = True
End Function

Function Open( )
     Open = 0
End Function

Function Close( )
     Close = 0
End Function

Function Terminate( )
    Resource.LogInformation “Entering Terminate”
     
    If Err.Number > 0 Then
      Resource.LogInformation Err.Details
      Resource.LogInformation oExec.StdErr.ReadAll
     End If
     Terminate = True
End Function

Function CheckProcess ()
    CheckProcess = 0
    strComputer = “.”
   
    Set objWMIService = GetObject(“winmgmts:” & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)
    Set colProcess = objWMIService.ExecQuery (“Select * from Win32_Process where Name = ‘” & processName & “‘”)
   
    On Error Resume Next
    For Each objProcess in colProcess
        CheckProcess = CheckProcess + 1
    Next
End Function

Function KillProcess ()
    strComputer = “.”
    Set objWMIService = GetObject(“winmgmts:” & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)
    Set colProcess = objWMIService.ExecQuery (“Select * from Win32_Process where Name = ‘” & processName & “‘”)
   
    On Error Resume Next
    For Each objProcess in colProcess
        Set objShell = CreateObject(“WScript.Shell”)
        objShell.Run “taskkill.exe /F /IM ” &
processName

        Resource.LogInformation “Killed rougue ” & processName & “ process…”
    Next
End Function

 

Categories
Windows 7

Windows 7: Mapped Drived Fail At Logon/Startup

Windows 7: Mapped Drived Fail At Logon/Startup

I cam across an issue recently where mapped drivers were not connecting at user logon. These drives were attached via the user account in AD (home drive) and via aVBS logon script.

This was resolved by setting the following registry key on the Windows 7 client:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
“EnableLinkedConnections”=dword:00000001

Categories
Exchange Server 2007

Exchange 2007 : You cannot open free/busy information

Exchange 2007 : You cannot open free/busy information

I had a user who was unable to add calendar entries to a Room Mailbox calendar. The error she received was:

You cannot open free/busy information. You do not have sufficient permissions to perform this opertation on this object.

This was caused by the user not having full mailbox permissions on the resource mailbox. Use the following command to configure mailbox permissions to allow the user to create new entries in the calendar:

Add-MailboxPermission -Identity “Room Mailbox 1” -User ‘domain\user’ -AccessRights ‘FullAccess’

You can also use the following command to apply this change to a number of similar named mailboxes, this command assumes that all the room names start with ‘Room’:

get-mailbox “Room*” | Add-MailboxPermission -User ‘domain\user‘ -AccessRights ‘FullAccess’
 

Categories
Windows Server 2003

Windows 2003 : Print Server Printer ‘Offline’

Windows 2003 : Print Server Printer ‘Offline’

I ran into an issue recently where a printer kept going into an ‘offline’ state. This would occur randomly and would require the print spooler service to be restarted on the print server.

The solution was simple:

  • Under the properties of the printer select the Ports Tab 
  • Select the Port and click Configure Port
  • Uncheck “SNMP Status Enable”

The printer will now return to an online state and will work again.