Showing posts with label IIS. Show all posts
Showing posts with label IIS. Show all posts

Thursday, December 3, 2015

The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported. Please enable the Service Broker for this database if you wish to use notifications.

Problem:

Loading the web application and received the following error:

The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported.  Please enable the Service Broker for this database if you wish to use notifications.

The database is installed and running but having issues bringing up the website.


Solution:

Option 1
ALTER DATABASE [DBNAME] SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE
  
Option 2




Source:
http://stackoverflow.com/questions/2758976/enabling-service-broker-in-sql-server-2008

Thursday, October 29, 2015

IIS private key export as base64 cert.

Problem:

I was trying to export an SSL public/private key from IIS.  This will export only as a pfx.  I needed it as a base64 encoded file.  This often happens with proxy servers which host a front end.  They don't seem to like pfx since they all tend to run Linux.

Solution:

Create a console application and programmatically create the cert file.

  m_X509CertificateThumbprint = Regex.Replace(rawThumbprintString, @"[^\u0000-\u007F]", string.Empty);
            m_X509CertificateThumbprint = rawThumbprintString.Replace("\u200e", string.Empty).Replace("\u200f", string.Empty).Replace(" ", string.Empty);
            var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
            store.Open(OpenFlags.ReadOnly);

            //var certificate = store.Certificates.Find(X509FindType.FindByThumbprint,
            //    "‎69c04af8588ec65762de96ddd51d78fa6e47c692", false)[0]; // doesn't matter how you get the cert
            var cert = store.Certificates.Find(X509FindType.FindByThumbprint, m_X509CertificateThumbprint, true);
            if(cert.Count > 0)
            {
                X509Certificate2 full = cert[0];
                Console.WriteLine(full.FriendlyName);
                var exported = full.Export(X509ContentType.Pfx, "1qaz@WSX");
                var base64 = Convert.ToBase64String(exported);
                System.IO.File.WriteAllText(@"C:\viper\aeitt.cer.txt", base64);


            }

            store.Close();

Source:
http://stackoverflow.com/questions/8863785/how-to-get-the-base-64-encoded-value-of-a-certificate-with-private-key
http://stackoverflow.com/questions/11115511/how-to-find-certificate-by-its-thumbprint-in-c-sharp

Wednesday, June 3, 2015

DISA PKI and PKE Tools

This tool allows users to install DoD production PKI, Joint Interoperability Test Command (JITC) test PKI, and External Certification Authority (ECA) CA certificates into their Windows and Firefox certificate stores. InstallRoot 4.1 is packaged with a command line version as well as an InstallRoot service, which can check for updated Trust Anchor Management Protocol (TAMP) messages that contain the latest certificate information from DoD. The following operating systems are supported: Windows XP, Windows Vista, Windows 7, Windows 8 and 8.1, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, and Windows Server 2012 R2.



Source:
http://iase.disa.mil/pki-pke/Pages/tools.aspx

Friday, March 13, 2015

Unrecognized attribute 'targetFramework'.

We have just move to new servers and trying to get the website up and running.  I ran into this error when I tried to run an aspx page.  The static files and asp files ran without issue.  As soon as the Framework was invoked, I popped this error.  This an easy one to fix.  Just look at the version of the framework for your application pool.  It is most likely set to something below 4.  Set it to 4.0 and the issue should be resolved.


This is the issue.  You are trying to invoke a higher level version of the framework on an app pool which is running a lower version of the framework.

Wednesday, August 13, 2014

Move Inetpub off of c drive

The inetpub folder is installed by default on the c drive. We often are asked to move this default folder onto an application drive (i.e. d, f, g drive). It is a convenient practice as it gets the files off of the c drive which can get clogged up with all kinds of system level files. Here is the script which will move an existing c:\inetpub install to the drive of your choice. Save it as inetpub.bat and then execute as c:\inetpub.bat f where f is the name of the target drive you want to run inetpub from. REM PLEASE BE AWARE: SERVICING (I.E. HOTFIXES AND SERVICE PACKS) WILL STILL REPLACE FILES REM IN THE ORIGINAL DIRECTORIES. THE LIKELIHOOD THAT FILES IN THE INETPUB DIRECTORIES HAVE REM TO BE REPLACED BY SERVICING IS LOW BUT FOR THIS REASON DELETING THE ORIGINAL DIRECTORIES REM IS NOT POSSIBLE. @echo off IF "%1" == "" goto err setlocal set MOVETO=%1:\ REM simple error handling if drive does not exist or argument is wrong IF NOT EXIST %MOVETO% goto err REM Backup IIS config before we start changing config to point to the new path %windir%\system32\inetsrv\appcmd add backup beforeRootMove REM Stop all IIS services iisreset /stop REM Copy all content REM /O - copy ACLs REM /E - copy sub directories including empty ones REM /I - assume destination is a directory REM /Q - quiet REM echo on, because user will be prompted if content already exists. echo on xcopy %systemdrive%\inetpub %MOVETO%inetpub /O /E /I /Q @echo off REM Move AppPool isolation directory reg add HKLM\System\CurrentControlSet\Services\WAS\Parameters /v ConfigIsolationPath /t REG_SZ /d %MOVETO%inetpub\temp\appPools /f REM Move logfile directories %windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/sites -siteDefaults.traceFailedRequestsLogging.directory:"%MOVETO%inetpub\logs \FailedReqLogFiles" %windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/sites -siteDefaults.logfile.directory:"%MOVETO%inetpub\logs\logfiles" %windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/log -centralBinaryLogFile.directory:"%MOVETO%inetpub\logs\logfiles" %windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/log -centralW3CLogFile.directory:"%MOVETO%inetpub\logs\logfiles" %windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/sites -siteDefaults.ftpServer.logFile.directory:"%MOVETO%inetpub\logs\logfiles" %windir%\system32\inetsrv\appcmd set config -section:system.ftpServer/log -centralLogFile.directory:"%MOVETO%inetpub\logs\logfiles" REM Move config history location, temporary files, the path for the Default Web Site and the custom error locations %windir%\system32\inetsrv\appcmd set config -section:system.applicationhost/configHistory -path:%MOVETO%inetpub\history %windir%\system32\inetsrv\appcmd set config -section:system.webServer/asp -cache.disktemplateCacheDirectory:"%MOVETO%inetpub\temp\ASP Compiled Templates" %windir%\system32\inetsrv\appcmd set config -section:system.webServer/httpCompression -directory:"%MOVETO%inetpub\temp\IIS Temporary Compressed Files" %windir%\system32\inetsrv\appcmd set vdir "Default Web Site/" -physicalPath:%MOVETO%inetpub\wwwroot %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='401'].prefixLanguageFilePath:%MOVETO%inetpub\custerr %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='403'].prefixLanguageFilePath:%MOVETO%inetpub\custerr %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='404'].prefixLanguageFilePath:%MOVETO%inetpub\custerr %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='405'].prefixLanguageFilePath:%MOVETO%inetpub\custerr %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='406'].prefixLanguageFilePath:%MOVETO%inetpub\custerr %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='412'].prefixLanguageFilePath:%MOVETO%inetpub\custerr %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='500'].prefixLanguageFilePath:%MOVETO%inetpub\custerr %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='501'].prefixLanguageFilePath:%MOVETO%inetpub\custerr %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='502'].prefixLanguageFilePath:%MOVETO%inetpub\custerr REM Make sure Service Pack and Hotfix Installers know where the IIS root directories are reg add HKLM\Software\Microsoft\inetstp /v PathWWWRoot /t REG_SZ /d %MOVETO%inetpub\wwwroot /f reg add HKLM\Software\Microsoft\inetstp /v PathFTPRoot /t REG_SZ /d %MOVETO%inetpub\ftproot /f REM Do the same for x64 directories if not "%ProgramFiles(x86)%" == "" reg add HKLM\Software\Wow6432Node\Microsoft\inetstp /v PathWWWRoot /t REG_EXPAND_SZ /d %MOVETO%inetpub\wwwroot /f if not "%ProgramFiles(x86)%" == "" reg add HKLM\Software\Wow6432Node\Microsoft\inetstp /v PathFTPRoot /t REG_EXPAND_SZ /d %MOVETO%inetpub\ftproot /f REM Restart all IIS services iisreset /start echo. echo. echo =============================================================================== echo Moved IIS7 root directory from %systemdrive%\ to %MOVETO%. echo. echo Please verify if the move worked. echo If something went wrong you can restore the old settings via echo "APPCMD restore backup beforeRootMove" echo and echo "REG delete HKLM\System\CurrentControlSet\Services\WAS\Parameters\ConfigIsolationPath" echo You also have to reset the PathWWWRoot and PathFTPRoot registry values echo in HKEY_LOCAL_MACHINE\Software\Microsoft\InetStp. echo =============================================================================== echo. echo. endlocal goto success REM error message if no argument or drive does not exist :err echo. echo New root drive letter required. echo Here an example how to move the IIS root to the F:\ drive: echo. echo MOVEIISROOT.BAT F echo. echo. :success

Wednesday, July 16, 2014

Connection string sytnax for IIS to SQL Server connection.

I always forget the syntax for connnection strings in my applications.  The guys at connectionsstrings.com do a great job but stumbled across another way to get at the correct syntax.


The steps below.


1.     Right-click an empty spot on the desktop and choose NEW, TEXT DOCUMENT from the context menu


2.     Save it with a .udl extension, and click yes when it asks are you sure.


3.     Double-click the new udl file you just created. It will open a dialogue. Go to the Provider tab, and choose the appropriate provider.


4.     Go to the Connection tab and fill in the server name and database name, and choose NT authentication (or use a specific username and password, which is SQL authentication). Now click Test Connection. If it works, you're ready to click OK and move on to the final step. If it doesn't you need to resolve permission issues, or you've mis-typed something.

5.     Now right-click the file on the desktop and open it in notepad. It will display the connection string that you can copy and paste to wherever you need it.