Archive for March 2011

 
 

Unable to Authenticate to Local Site? Disable Loopback Check

This one never gets old. Everytime we want to install SharePoint, we tend to continue to work on the server getting as much done as possible. And, everytime, we’re confronted with the inability to authenticate using Windows username and password and a browser on the web front end server.

You try so carefully to enter your DomainName\UserName and password exactly correctly and hit enter, enter, enter and you get a 401 or, worse, just a blank screen. As we’ve learned, what we’ve encountered is the dreaded anti-loopback monster.

Now, the ALM is a fine security measure on a server that you deploy and then spend the rest of your life as a SharePoint admin working from another workstation. It simply prevents authentication from the local machine using host headers other than the machine name. It’s detailed here on support.microsoft.com. Apparetly the threat is a “Reflection Attack” which reminds me of my mirror on the occasional Sunday morning before my shower.

Essentially, we’re creating a two registry keys:

  1. DisableLoopbackCheck dword registry key with a decimal value of 1 in the HKLM\SYSTEM\CurrrentControlSet\Control\Lsa hive. 
  2. DisableStrictNameChecking dword registry key with a decimal value of 1 in the HKLM\SYSTEM\CurrrentControlSet\Services\
    LanMan
    Server\Parameters hive.

Once we restart, we should be able to access our sites locally using the propery credentials. Of course, this is a “must have” kind of thing if you’re building a development box where you’ll be accessing the WFE from the local machine in Visual Studio.

hth
-robot

SharePoint 2010 Chart Web Parts

So we’ve had a couple of cycles through the 2010 Chart Web Part. It’s a pretty cool thing that your higher level stakeholders will probably love and they’re pretty easy to deploy.

We have a couple of great resources from our new best friends, Corey, Channel 9 and PointBridge.

hth
-robot

Looking at the WCF Demo

The heart of Service Oriented Architecture is the interaction between services. These used to all be “web” services that ran on web servers and traveled via http through ports 80 and 443. Recently, they’ve become more generic using tcp through any port and, so, they’re not web services any more, they’re just services.

Microsoft supports the interaction between services using the Windows Communication Framework (WCF) that connects services with clients and hosts. The demonstration of these components is pretty simple.

If we need information or we need someone to manipulate some information we already have, we’ll meet that need by identifying a provider. We’ll access the provider’s service. We’ll avail ourselves of the service’s solution by accessing it’s  endpoint. The endpoint defines three things:

  • The service location.
  • The binding – The information needed to interact with the service.
  • The contract – The definition of the functionality the service provides.

 The demos include:  

  1. Define a service and its contract.
  2. The service implementation.
  3. Configuring, hosting and running the service.
  4. Create a client proxy.
  5. Configure the client application.
  6. Create and run the client.

1. Define the Service, the Contract and Its Interface

Open Visual Studio 2010. Select File | New | Project.

Select a new console application. Give it a name and a location.

Right click on the Service project in Solution Explorer and select Properties. on the Application tab of the properties dialog change the default namespace to:

Microsoft.ServiceModel.Samples.

On the Program.cs page, make the same change to the namespace.

Rightclick on the project again and select Add Reference. On the .NET tab, select System.ServiceModel and click OK.

Add a using statement for System.ServiceModel in Program.cs.

Within the namespace, but after the Program class, add the service contract on our new namespace and its interface, ICalculator

[ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples")]
public interface ICalculator
{
  [OperationContract]
  double Add(double n1, double n2);
  [OperationContract]
  double Subtract(double n1, double n2);
  [OperationContract]
  double Multiply(double n1, double n2);
  [OperationContract]
  double Divide(double n1, double n2);
}

2. Create the Contract

After the ICalculator interface code, add a new class that implements the interface:

public class CalculatorService : ICalculator
{
public double Add(double n1, double n2)
   {
       double result = n1 + n2;
       Console.WriteLine("Received Add({0},{1})", n1, n2);
       Console.WriteLine("Return: {0}", result);
       return result;
   }
   public double Subtract(double n1, double n2)
   {
       double result = n1 - n2;
       Console.WriteLine("Received Subtract({0},{1})", n1, n2);
       Console.WriteLine("Return: {0}", result);
       return result;
   }
   public double Multiply(double n1, double n2)
  {
       double result = n1 * n2;
       Console.WriteLine("Received Multiply({0},{1})", n1, n2);
       Console.WriteLine("Return: {0}", result);
       return result;
  }
   public double Divide(double n1, double n2)
   {
       double result = n1 / n2;
       Console.WriteLine("Received Divide({0},{1})", n1, n2);
       Console.WriteLine("Return: {0}", result);
       return result;
   }
} 

3. Configuring, hosting and running the service.

Within the Main() method of the Program class, set the service’s base address:

Uri baseAddress =
   new Uri(http://localhost:8000/ServiceModelSamples/Service);

 Then provide the hosting details, add the using statement:

using System.ServiceModel.Description;

Create the ServiceHost:

ServiceHost selfHost =
   new ServiceHost(typeof(CalculatorService), baseAddress);

Then, add a try\catch block to add the endpoint:

try
{
   selfHost.AddServiceEndpoint(
       typeof(ICalculator),
       new WSHttpBinding(),
       "CalculatorService");

Enable the metadata exchange:

ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
selfHost.Description.Behaviors.Add(smb);

Create the open and close methods:

selfHost.Open();
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
selfHost.Close(); 

 Close the try block and add the catch block to itself in the event of an error:

}
catch (CommunicationException ce)
{
    Console.WriteLine("An exception occurred: {0}", ce.Message);
    selfHost.Abort();
}

 At this point, you can run the service, either in Visual Studio or by clicking on the .exe in the project folder. Apparently there’s some goofiness with Windows Vista that requires you to do these as administrator but I’m not sure if a user in the local admin group will suffice. You’ll see the little black box pop up and then it will take an Enter keystroke to kill it.

You can also browse to the noted Uri and get a cool little “You have created a service.” page.

4. Create a client proxy.

 

 

References:

MSDN: Getting Started Tutorial

MSDN: Host a WCF Service in IIS

MSDN: Configuring Services Using Configuration Files

MSDN: ServiceModel Metadata Utility Tool (SvcUtil.exe)



Welcome, Again, To SharePoint from Scratch

It’s a new day…

SharePoint from Scratch has moved to a commercially hosted provider. We may cover those details in a post soon. Otherwise, your best robot friend is making a move away from the huge grindstone of the full-time corporate world so he can spend more time with his readers, you, and do what he was born to do, make it clear how to get things done when you’re starting from scratch.

So there’s a million things going on accordingly. But as my best reader friends, you probably care little about all of that. You’re here because you just want to know: “How do I make this doggone thing work?”

Well, the way this robot works is by making a list of doggone things:

  1. SharePoint Server 2010
  2. All the Stuff the SharePoint 2010 does.
  3. All the other complicated technical stuff  that the boss wants.

Now, this robot can teach you or he can tell you; that means you can “do” or you can “learn.” It’s a fish-fish thing. For those of you that just want fish, we’ll get to that. For those of you that want to fish, we have a brand new option: The Understanding SharePoint Journal (USPJ) and the USPJ Academy (USPJA) If SharePoint has you scratching your head, consider the Acadeny your marigold shampoo.

Now the guys and gals that run that show include several highly respected members of the SharePoint community and a newbie, your’s truly.

So we’ve just completed our first Beginning SharePoint Adminstration class and I must say, this robot is impressed with both the academy and it’s leadership as well as its student body. If you want to get involved with a group of folks that know how to collaborate and conquer, I’ve got a great group I’d like to introduce you to.

More about the Academy, its mission and its leadership will undoubtedly follow. But for now, let’s just say, it’s good to be refocused, to reduce the grindstone nose buildup and to ramp up the new SharePoint from Scratch. Someone said it’s all about “Winning.” Some of us weren’t born in the lead but learned what it takes to start gaining ground. Let’s get to it.

-robot