Tuesday, February 23, 2016

Log Parser

Covert the time

LogParser.exe "SELECT DATE,TO_LOCALTIME(time) AS time,s-ip,cs-method,cs-uri-stem,cs-uri-query,s-port,cs-username,c-ip,cs(User-Agent),sc-status,sc-substatus,sc-win32-status,time-taken INTOc:\ayman\output.log FROM c:\ayman\input.log" -i:IISW3C -o:W3C


Wednesday, February 17, 2016

ADFS 3.0 stops working after reboot

Background :
With the arrival of ADFS 3.0 in Windows Server 2012 R2 the use of IIS with AD FS in Windows Server 2012 R2 has been eschewed in favour of a move to kernel-mode (HTTP.SYS). The motive is to improve performance, provide greater sign-in customization options and to be able for co-locating ADFS and AD Domain Services on the same server (IIS on domain controllers is from a security perspective a big no-no).
As the use of federation services goes more mainstream in everyday use with Windows 8.1, office 365 , intune , azure and whatever cloud service they come up with , this shift is understandable and an important design consideration.  With the new kernel-mode approach, support for running under server core also appears as an option in the new release.
Problem :
In my lab , I Installed and configured ADFS 3.0 om my domain controller with a global managed service account (gmsa). This is a new feature since ADDS 2012 was introduced. After a server reboot , the ADFS services cannot start anymore and it always stay in "starting" state , making your DC unusable.
This issue appears to be gMSA related, when you install ADFS 3.0 on a 2012R2 running AD DS, than after the reboot (not always) gMSA fails to authenticate on behalf of the ADFS Service under which the service is configured to run.
Solution:
After investigation, I found an unacceptable workaround, which is to :
1. Reboot the ADDS/ADFS3.0 server, logon and immediately set the ADFS Service from Automatic (Delayed) to Manual.
2. Change the Microsoft Key Distribution Service (kdssvc) service to auto (instead of manual trigger) and restart the DC.
3. Logon and start the ADFS service (starts successfully)
4. Set the ADFS Service from Manual to Automatic (Delayed) .
5. Done.
Keep it coming. We’re all learning ADFS 3.0 for Windows Intune  :-)

Enable Basic Authentication in IIS Express

go to
%USERPROFILE%\Documents\IISExpress\config\applicationhost.config: 
and then search for basicauthentication in there and set it to true.

<basicAuthentication enabled="true" />


Sunday, January 31, 2016

Change Feature Delegation for IISExpress

IIS EXPRESS - TURNING ON WINDOWS AUTHENTICATION

 
 Posted In: iis
Time to Read: 1 min
So I brought up a new machine and tried to run my ASP.NET web site in IIS Express that uses Windows Authentication and was greeted with the following error:
Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Details:
This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=”Deny”), or set explicitly by a location tag with overrideMode=”Deny” or the legacy allowOverride=”false”.

Solution

Every time I bring up a new machine I always forget to update the IIS Express setting to fix this error and have to do a google search to figure out where the IIS Express configuration is stored. So I figured I should finally document the fix for it.
The error is caused by this section in the web.config
<system.webServer>
 <security>
  <authentication>
   <windowsAuthentication enabled="true" />
   <anonymousAuthentication enabled="false" />   
  </authentication>
 </security>
</system.webServer>
To fix this open up the IIS Express applicationhost.config. This file is stored at C:\Users[your user name]\Documents\IISExpress\config\applicationhost.config
Update for VS2015+: config file location is $(solutionDir).vs\config\applicationhost.config
Look for the following lines
<section name="windowsAuthentication" overrideModeDefault="Deny" />
<section name="anonymousAuthentication" overrideModeDefault="Deny" />
<add name="WindowsAuthenticationModule" lockItem="true" />
<add name="AnonymousAuthenticationModule" lockItem="true" />
Change those lines to
<section name="windowsAuthentication" overrideModeDefault="Allow" />
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
<add name="WindowsAuthenticationModule" lockItem="false" />
<add name="AnonymousAuthenticationModule" lockItem="false" />
Save the file and refresh your asp.net web page. It may take a moment to load as it load the new configurations into IIS Express.

Thanks to :
http://digitaldrummerj.me/iis-express-windows-authentication/

Tuesday, March 24, 2015

Third Party dll in SSIS Projects

I came across a requirement to access third party dlls in SSIS Package. which is fairly easy. the tricky part is where to deploy those third party dlls. In almost all the blogs that i came across while search the solution, I was told to deploy them in GAC. Which I don't think ideal solution in all the environment. Let me move to solution directly.

- Create a parameter that hold the directory which has all the third party files.
- Pass the variable name in Script
- In your Script, add following line.
 AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

best place to add this is in PreExecute. This will call the attached event handler whenever it will try to load a third party dll.

And add the related event handler in the same class.

Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
    {
       
        if(args.Name.IndexOf("MyCustomDll1.dll")>0)
            return Assembly.LoadFile(Path.Combine(Variables.SupportDirectory,"MyCustomDll1.dll"));
        else if(args.Name.IndexOf("MyCustomDll2.dll")>0)
            return Assembly.LoadFile(Path.Combine(Variables.SupportDirectory,"MyCustomDll2.dll"));
        else
            return Assembly.GetExecutingAssembly();
    }
It is important to return the executing assembly in else.

 -That's it. now it will load all the dll from the folder that you have specified. You just need to make sure that the files exist in that folder.

Thanks,
HP

Sunday, May 4, 2014

Wednesday, September 12, 2012

Debugging Hang/Crash Dumps

A very good article that can be used to debug hang or crash dumps.
http://www.infosysblogs.com/microsoft/2009/06/troubleshooting_wcf_service_ap.html

you may face certain issues while debugging.
Here is the link that helped me fix the issues that came across my debugging.
http://blogs.msdn.com/b/dougste/archive/2009/02/18/failed-to-load-data-access-dll-0x80004005-or-what-is-mscordacwks-dll.aspx

This will help identify memory leaks by type.
http://stackoverflow.com/questions/9016834/detect-wcf-channel-leaking-using-windbg


http://blogs.msdn.com/b/alikl/archive/2009/02/15/identifying-memory-leak-with-process-explorer-and-windbg.aspx?Redirected=true

To debug 32 bit dump on 64 box.
http://blogs.msdn.com/b/msdnforum/archive/2010/03/14/how-do-i-switch-to-32bit-mode-when-i-use-windbg-to-debug-a-dump-of-a-32bit-application-running-on-an-x64-machine.aspx

http://romikoderbynew.com/2011/05/07/memory-dump-analysisw3wp-iis-process/

Hang dump analysis.
http://codemachine.com/article_rpcchain.html



.load sos
!EEStack
to get full stack trace including managed thread. 
If issue loading sos dll then for  for 4.0 application
.loadby sos clr command should be used.

Follow this blog which has step by step information on how to debug a hang dump.
http://romikoderbynew.com/2011/05/07/memory-dump-analysisw3wp-iis-process/



Copy mscordacwks.dll, sos.dll and clr.dll from target machine and then copy it to your machine and run command
.load  "path of sosdll"
to get rid of sos version mismatch error.

To Load the symbols:
  1. Load the dump file.
  2. Run .symfix
  3. Open the 'Symbol File Path' menu
  4. Add a path to your application's .PDB files
  5. Check the 'reload' checkbox
  6. Run !clrstack -p to dump the stack with parameters.