Tuesday 14 May 2013

Security settings for this service require Windows Authentication but it is not enabled for the IIS application that hosts this service

I am getting this error while I am trying to run my WCF service using HTTPS.
Then I have done the following to resolve my issue.

1 - The Contract Operation method has Operation Behaviour "
      [OperationBehavior(Impersonation=ImpersonationOption.Required)]"

2 - Change the following in the web.config file.
      <system.web>
            ....
            <authentication mode="Windows" />
            .....
     </system.web>

3 - You can also verify that Anonymous Authentication is disabled like in the image below in the IIS.
      Open IIS. Select your application from left side. From right side select "Authentication".
     
     In my case "Windows Authentication" is disabled. Click on the status to enabled.

    Run your application.


Saturday 11 May 2013

Execution of user code in the .NET Framework is disabled. Enable "clr enabled" configuration option.


While running a project I got this error:
Execution of user code in the .NET Framework is disabled. Enable "clr enabled" configuration option.
Execution of user code in the .NET Framework inside the database is disabled.
Execute this TSQL:  "sp_configure 'clr enabled',1" and "RECONFIGURE"
So to fix this run this TSQL inside the database.
sp_configure 'clr enabled',1
GO
RECONFIGURE

Tuesday 7 May 2013

The database owner SID recorded in the master database differs from the database owner SID recorded in database 'AdventureWorks2008R2'. You should correct this situation by resetting the owner of database 'AdventureWorks2008R2' using the ALTER AUTHORIZATION statement.

--To get owner SID recorded in the master database for the current database
SELECT owner_sid FROM sys.databases WHERE database_id=DB_ID()

--To get the owner SID recorded for the current database owner
SELECT sid FROM sys.database_principals WHERE name=N'dbo'

They should return you same SID values in the format of a GUID.

Now if the two SID's differ which they did in my case it means that you need to reset the database owner so that both values are the same. To do this you can run another ALTER statement and pass in the owner value you want to use e.g

use AdventureWorks2008R2

ALTER AUTHORIZATION ON Database::AdventureWorks2008R2 TO sa

or

DECLARE @Command VARCHAR(MAX) = 'ALTER AUTHORIZATION ON DATABASE::<<DatabaseName>> TO [<<LoginName>>]'
SELECT @Command = REPLACE(REPLACE(@Command,'<<DatabaseName>>',SD.Name), '<<LoginName>>', SL.Name)
FROM master..sysdatabases SD
JOIN master..syslogins SL ON  SD.SID = SL.SID
WHERE  SD.Name = DB_NAME()

PRINT @Command
EXEC(@Command)

The problem will be fixed.