Sunday, 31 March 2013

Windows 2008 Password Complexity

To ensure that accounts being created on your server meets the standard password requirement . This can be enforced on a Win 2008 server by following below steps:

1. Click Start > Run, type gpedit.msc > click OK

2. Computer Configuration > Windows Settings > Security Settings > Account Policies > Password Policy.

Unable to shrink database log file ( DBCC shrinkfile gives error)

Sometimes when trying to shrink the database log file for Ms SQl Database using DBCC SHRINKFILE ('database-name_Log', 1), which is the name for log file. It gives the following error :

"Could not locate file  xxx_Log for database  in sys.database_files. The file either does not exist, or was dropped. "

Solution :

The file name should be the logical file name and not the physical file name. Look in the Database properties, on the Files tab for the Logical Name of the file you are trying to shrink, and use that name.

Alternately, you can run the following query in the respective database from Ms Sql Managment Studio to get the logical name

SELECT df.name FROM sys.database_files AS df WHERE df.type_desc = 'log'

The media family on device is incorrectly formed. SQL Server cannot process this media family Error: 3241

When you try to restore a backup of the database you get the following error:


The media family on device ” is incorrectly formed. SQL Server cannot process this media family.
RESTORE HEADER ONLY is terminating abnormally. (Microsoft SQL Server, Error: 3241)

This error occurs due to the following problems:

1. Backup file is corrupted.
2. Backup was taken on a higher version of SQL Server and restoration is being done on the earlier version.

Fix :

1. If you feel backup could be corrupted take the backup again
2. If you are using FTP then use it in binary mode to copy the backup file into local drive
3. If the versions are different then update the SQL Server on the system into which the backup has to be restored
4. Verify the database backup to check what the issue is.

The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine

This error you can get while compiling an application in machines like x64 or x86.

There are two solutions to it :
 
1) If you are in development (Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine)
To solve this issue open the project in Visual Studio then:
1. From the solution explorer right-click on project name then click on Properties
2. Click on the Build tab
3. Change Platform target from: Any CPU to x86
4. Re-build your solution
5. You are good to go
 
2) If your application is hosted on IIS(Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine)

This will happen if you have an Ms Office application/DLL incorporated in you application, Very simple steps
1) Open IIS manager
2) Select Application Pools
3) Select the application pool you are using in your website
4) Click on Advanced Settings in the right-pane of the window.  
5) Under General section, set "Enable 32-Bit Applications" to "True".
6) Done.

SQL Warning in Functions.php on line .....The function php_uname()

You get the following error when trying to access your site which uses database :

Warning: The function php_uname(), which your Script uses, was deactivated for safety reasons and cannot not be used.

That isn't an SQL error, it is due to your application is trying to determine the server load and is using a function which your web host must have disabled.

On that line, you should find:

elseif(substr(php_uname()...

Change it to

elseif(substr(@php_uname()..

And you shouldn't receive that message anymore.

Shrinking Truncate SQL SERVER Log File

Following code always shrinks the Truncated Log File to minimum size possible.

USE DatabaseName
GO
DBCC SHRINKFILE(<TransactionLogName>, 1)
BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY
DBCC SHRINKFILE(<TransactionLogName>, 1)
GO 

You are recommended to take full back up right before/after above query.

Roles and Features showing an error HRESULT: 0x800F0818 in Server Manager of windows server 2008 R2

When you open Server Manager both Roles and Features display Error and you are unable to add any role or features. When you select the details link it displays error: HRESULT: 0x800F0818.

You also get the event ID :1601 in event logs.


Rsolution:
1) Browse to c:\Windows\Logs\CBS\


2) Copy the CBS.log to c:\Temp


3) Search the file for errors: corruption or failed


Example:
2012-01-10 19:47:55, Info  CBS  Mark store corruption flag because there is a
mismatch between package identity
package:
Package_for_KB2511455_RTM~31bf3856ad364e35~amd64~~6.1.1.0.
[HRESULT= 0x00000000 - S_OK] 2012-01-10 19:47:55, Info CBS Identity mismatch:
Specified Identity:Package_for_KB2511455_RTM~31bf3856ad364e35~amd64~~6.1.1.0,
actual package Identity:
Microsoft-Windows-Foundation-Package~31bf3856ad364e35~amd64~~6.1.7600.16385
[HRESULT = 0x800f0818 - CBS_E_IDENTITY_MISMATCH] 2012-01-10 19:47:55, Info
CBS  Failed to resolve package [HRESULT = 0x800f0818 - CBS_E_IDENTITY_MISMATCH]


4) The above highlighted text indicates that there is an issue with the KB2511455.


5) Download KB2511455 update.


6) Unpack the downloaded KB using the following command:
    Expand -F:* UpdateKBXXXX.msu c:\Temp\KBXXXX_Unpackage


7) After you expand the file you will see UpdateKBXXXX.cab File. Expand it as well using the following command:
    Expand -F:* UpdateKBXXXX.CAB c:\Temp\KBXXXX_Unpackage\CAB


8) Run the following command for taking ownership to the c:\Windows\Servicing\Packages folder.
    takeown /F c:\Windows\Servicing\Packages /D y /R


9) Give a full access to your user account to the c:\Windows\Servicing\Packages folder.


10) Explore c:\Windows\Servicing\Packages folder and rename the following files :
    package_for_kb2511455_rtm~31bf3856ad364e35~amd64~~6.1.1.0.cat
    package_for_kb2511455_rtm~31bf3856ad364e35~amd64~~6.1.1.0.mum


11) Copy the above files from c:\Temp\KBXXXX_Unpackage\CAB
 to c:\Windows\Servicing\Packages folder


12) Server Manager should open as expected now.