Thursday, October 20, 2011

Blogger : Formating a code snippet.

There's many suggestions for this.

Refer my question on stackoverflow.

However, the TechNet wiki recommends tohtml. Just paste in your code snippet, select the language, click the button, copy the resulting html and paste back into whatever.

I use the white style.

Neat!

Enjoy!

Monday, October 10, 2011

TechNet : 15 minutes of fame

 

Over on the TechNet Wiki, I contributed an article on a Kerberos Survival Guide. 

Just been notified that:

The article Kerberos Survival Guide on the TechNet Wiki has achieved its 15 minutes of fame. Congratulations!

To clarify:

As you can see here: How do I earn points?,  the points you get range between 5 and 2,500 points when your article gets from 500 to 1 million page views. "15 minutes of fame" is the first milestone.

Enjoy!

Monday, October 03, 2011

ASP.NET : Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list

 

I do a lot of work developing applications on my Windows 7 32 bit machine using IIS 7.5 and then migrating them to IIS 7.5 on my Windows Server 2008 R2 64 bit box. Not as simple as it sounds.

Using VS 2010, my DefaultAppPool on Windows 7 uses the .NET 4.0 framework whereas it’s 2.0 on Windows 2008. So you need to make a new application pool and set it to “Integrated” and the 4.0 framework.

OK – then I get the above error. The blurb below on the error page says that the most likely cause is that:

“Managed handler is used; however, ASP.NET is not installed or is not installed completely.”

Check my installed features in IIS 7.5 and Yup – ASP.NET is installed, it has a handler etc. So WTF?

Mr. Google to the rescue.

Run a command prompt in administrative mode.

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -i
Start installing ASP.NET (4.0.30319).
..................
Finished installing ASP.NET (4.0.30319).

Note: Your version of the framework may be different!

Notice that it installs ASP.NET even though it is already supposed to be there but it fixes the problem and all is well!

Enjoy!

Tuesday, September 27, 2011

WCF : WCF Test Client “The contract ‘IMetadataExchange’ in client configuration does not match the name in service contract”

 

Playing around with WCF web services in VS 2010 and .NET Framework 4.

When I run the WCF Test Client across the web service I get the above error. The service still works but there’s an error symbol (a ! in a red circle on the LHS).

Mr. Google to the rescue and you need to change the framework config file here:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config

Comment out the “endpoint” section i.e.

<client>
  <!-- <endpoint address="" binding="netTcpRelayBinding" contract="IMetadataExchange" name="sb" /> -->
<metadata>

Problem solved.

Even though it still works, I hate these niggly errors in case I’ve screwed up Smile

Enjoy!

Thursday, September 22, 2011

ADFS : Google top 5 hits

I was looking at my blog stats and noticed that my article on "Re-installing ADFS v2.0" was among my top 5 articles.

So I Googled ""Re-installing ADFS v2.0" and found that the top 5 search entries in Google all point to my blog!



Note that the last one is actually from an aggregate site that points to the same blog entry.

Looking at the stats for this article. I noticed that the biggest source of queries was from the Geneva forum, the next was from stackoverflow and Mr. Google only came in third.

The message is clear - if you want to bump up your search results, write good, solid, factually correct articles and link to them. :-)

Enjoy!

Tuesday, September 20, 2011

ASP : Displaying server variables


Sometimes you need to know who you are logged in as.

In the claims world, it’s easy because you have the IPrincipal and IIdentity objects but if these are not available, you need to go back to first principles.

Enter stage left the server variables. These are accessed from the Request object. A simple way to enumerate then all is via the html segment below which you just whack into an asp page.

<html>
    <body>
    
        <h1>ASP Request Variables Page</h1>

        <h2>
            The current user you are logged in as is: 
            <u>
                <!-- <%=Request.ServerVariables("AUTH_USER" & "<br />") %> -->
                
                <%= response.write("AUTH_USER" & "    " &  Request.ServerVariables("AUTH_USER") & "<br /><br />") %>
            <u>
        </h2>
                
            <%
                for each x in Request.ServerVariables
                    response.write(x & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" &  Request.ServerVariables(x) & "<br /><br />")
                next
            %> 
            
    </body>

</html>

Enjoy!


Monday, September 12, 2011

ADFS : Selecting claim that's not in the default drop down


When you want to edit the claims rules for a CP or RP in ADFS v2.0, you sometimes need to select an LDAP attribute that's not in the default drop down list.

I've always done this via a custom claim, But then I read this post: Active Directory attribute store: Require custom claim rule to access other attributes?.

The drop down actually allows free-form (not that that is obvious). In case the link disappears, this is how:

"Edit Claims Rules / Add Rule / Send LDAP Attributes as Claims".
Don't select the drop-down, just click in the white space of the grid.
If the box turns dark blue, click again.
Away you go - you can now enter any attribute you like.

This also works for the "Outgoing Claims Type" box.

Enjoy!

Stackoverflow : Another milestone


Just clocked up rep. of 6000 over on Stackoverflow !!!

My stackoverflow flair:

profile for nzpcmad at Stack Overflow, Q&A for professional and enthusiast programmers

or overall Stack Exchange flair

profile for nzpcmad on Stack Exchange, a network of free, community-driven Q&A sites

Enjoy!

Thursday, September 08, 2011

Windows : The “hidden” tools

 

There’s an amazing amount of tools “hidden” on your PC that you probably aren’t even aware off Smile.

A lot of them are stored in the

C:\Program Files\Microsoft SDKs\Windows

directory. These mainly derive from the Windows SDK for Windows 7 and .NET Framework 4.

Browse through StartTools.htm located at:

C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin

There’s an amazing collection of tools there.

The actual binaries are located here:

C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin

To quote:

“The Windows SDK tools are designed to make it easier for you to create, deploy, and manage applications and components that target Windows and the Internet. The Windows SDK includes tools for both the .NET 3.5 SP1 and 4 Frameworks - a managed programming model - and tools for Win32® - the native (unmanaged) programming model for Windows. Many of the Windows SDK tools are listed on this page and categorized by target audience: managed, native and "common" (tools that could be used by either managed or native developers).”

Enjoy!

Friday, September 02, 2011

PowerShell : Using an IDE

 

PowerShell is command line which means that you lose out on all the benefits that an IDE brings.

There is an in-built PowerShell IDE:

Just type “ise” from the command line

but it’s pretty basic.

Then I came across PowerGui.

It has two parts viz. an administrative console that allows you to run a collection of PowerShell scripts and a script editor that allows you to enter and run scripts. It has intellisense and a set of built in snippets. It has a debug function where you can step through the script and examine all the variables.

Very neat – and BTW it’s free.

Enjoy!

Monday, August 29, 2011

AD : Displaying the SPN

 

SPN stands for Service Principal Name – used (among others) by Kerberos.

Normally, you work with them via the Setspn tool.

e.g.

setspn –l <account name>

which lists all spns assigned to that account.

However, you can also do this by:

Start – Administrative Tools – Active Directory Users and Computers – View – Advanced Features

Then navigate to the account via the tree. Right click – Properties – Attribute Editor tab. Then scroll down to servicePrincipalName and double-click.

You can add and remove SPN’s from this window as well. (i.e. the equivalent of setspn –a … or setspn –d …).

Enjoy!

Monday, August 22, 2011

WIF : The pipe endpoint 'net.pipe://localhost/s4u/022694f3-9fbd-422b-b4b2-312e25dae2a2' could not be found on your local machine.

 

If you are using WIF and C2WTS and you get the above error, it’s probably because the C2WTS service is not yet started.

It’s this one in the Services windows (which is in the “Administrative Tools” menu):

“Claims to Windows Token Service”

and the description is:

“Service to convert claims based identities to windows identities”

Note that you must use Windows domain user accounts. These accounts must have a Universal Principal Name (UPN).

Enjoy!