Geeks With Blogs

Tangible Thoughts SharePoint, MOSS? and all the other questions

My earlier frustration with a programming issue I had with SharePoint Portal Server Single Sign On (SPS SSO) came to the attention of very nice chap inside Redmond . All I can say about this chap is that he is very nice, goes by the name of Chris, and works with SharePoint Portal Server; Did I say he was nice guy already? Well anyway he is a nice chap.

He was able to throw a suggestion at me that actually bowled me over. It was one of those things that go totally un-noticed until someone points it at you.

Anyways here is the low-down on the Credentials.SetCredentials() method as I understand it. Chris correct me if I go wrong or add anything if you feel is necessary, and thanks for the info below.

  1. The Microsoft.SharePoint.Portal.SingleSignon.Credentials.SetCredentials() method needs to be called on an HTTP POST (i.e. postback), so Button/LinkButton clicks or anything else that would generate a postback is the way to go.

  1. If you are creating an Aspx page that would call the Credentials.SetCredentials() method, then the add form digest as a server control to the html code

<SPSWC:SSOFormDigest runat="server" ID="SSOFormDigest1" />

When developing a WebPart, something that didn’t work for me was adding

FormDigest object to the WebPart.

  1. Alternatively even if you are creating a WebPart you can add the current page to the Single Sign On Canary Checker like shown below when the page is loading. Please note it is important that the Page be added to the CanaryChecker before it is dispatched to the browser. So if you are creating a WebPart you can add the following code to OnInit(), OnLoad() or CreateChildControls()

Microsoft.SharePoint.Portal.SingleSignon.SSOCanaryChecker.AddCanary(Page);

      I was also informed that only one of above points (i.e. 2. or 3.) should be done, not both.

Now my suspicions are that page, whether it be a WebPart Page or Aspx page should be added the Canary Checker so that on postback when the SetCredentials() method is called the page will be successfully validate. Now I am able to vaguely piece together the role of the Canary although I still am not too sure.

Here is what the resulting WebPart Code looks like (only essential snippets are shown)

                       

            protected override void OnInit(EventArgs e)

            {

                  base.OnInit (e);

                  SSOCanaryChecker.AddCanary(Page);

            }

            …

protected override void CreateChildControls()

            {

                  btn = new Button();

                  btn.Text = "Set SSO Credentials";

                  btn.Click += new EventHandler(btn_Click);

                  Controls.Add(btn);

            }

            …

            private void btn_Click(object sender, EventArgs e)

            {

                  try

                  {

                        string[] rgSetCredentialData = new string[5];

                        rgSetCredentialData[0] = "sky";

                        rgSetCredentialData[1] = "rb26dett”;

                                   

                        Credentials.SetCredentials(1,

                              “ApplicationName”,

                              rgSetCredentialData);

                  }

                  catch (SingleSignonException esso)

                  {

                        switch (esso.LastErrorCode)

                        {

                              case SSOReturnCodes.SSO_E_CANARY_VALIDATION_FAILURE :

                              {

                                    // Do something to communicate the error

                                    break;

                              }                      

                        }                

                  }

            }

            protected override void RenderWebPart(HtmlTextWriter output)

            {

                  btn.RenderControl(output);

}

Thanks again for this info Chris and may your frags be plenty J.

Posted on Friday, September 10, 2004 3:50 PM SharePoint | Back to top


Comments on this post: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.

# re: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.
Requesting Gravatar...
I'm trying to use "GetCredentials" from a web service, but it keeps giving an error "access denied", it works fine if i'm in a windows form app. I have the SSO ticket passed as parameter, how can I get the username/password credentials?

Please help!!

Cal
Software Engineer
Left by Cal on Sep 24, 2004 12:47 AM

# re: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.
Requesting Gravatar...
try contacting me through the link at the top of the site, i might be able to help you
Left by tariq on Oct 18, 2004 11:25 AM

# re: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.
Requesting Gravatar...
Hi

I could not use your code. SSOCanaryChecker.AddCanary(Page) draws an exceprion with message "Request failed". I wrote a simple webpart and put the above code in it. what is wrong with it? the application definition and sharepoint sso configuration is correct.
Left by hamid on Nov 08, 2004 12:00 PM

# re: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.
Requesting Gravatar...
What was the type of exception thrown?
try contacting me throught the blogs contact me option, and I'll lend a hand.
Left by Tariq on Nov 09, 2004 3:11 AM

# re: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.
Requesting Gravatar...
I had exactly the same problem. I applied the fix described by the nice guy.
It worked in our development environments, but when we deployed the code to production it failed again.
I observed that the call to SetCredentials actually changed the value in the credential, but it throws the SSO_E_CANARY_VALIDATION_FAILURE.

The difference between the production and the development envionrment is that the production box is a 4 CPU box and the development is only a 1 CPU box. I am not sure if that could be the reason.?

I am also not sure whether one is allowed to call multiple times AddCanary on the same page?
We basically have two webparts, both make a call to AddCanary and both webparts are shown on the same page.

Any comments or suggestions would be highly appreciated.
Left by Gallus on Nov 15, 2004 5:10 PM


# re: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.
Requesting Gravatar...
I have the same error with SetUserCredentials,SetCredentials "Microsoft.SharePoint.Portal.SingleSignon.SSOCanaryChecker.b() " in a WEB SERVICE. Have you got any suggestion?
Thank you in advance.
Left by Paola on Jan 25, 2005 4:55 PM

# re: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.
Requesting Gravatar...
I have had better luck with putting SSOCanaryChecker.AddCanary(Page) in PreRender.
Left by bonam on Feb 01, 2005 8:39 PM

# re: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.
Requesting Gravatar...
Hi Tariq,

I'm having a similar problem with the SSOCanary in a web service, and I was wondering if you have a solution for that scenario.

Alternately, could you pass me the contact info for Chris (The Nice Guy)? I'm from MS too so hopefully he won't mind me picking his brains.

Thanks!

-Addy Santo
Left by Addy Santo on Apr 06, 2005 10:35 PM

# SSO Save credentials
Requesting Gravatar...
<P>I have a web part where I want to use my custom panel and custom tool part to
Left by Simon Tocker's BinaryJam on May 05, 2005 4:08 PM

# re: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.
Requesting Gravatar...
I have the "Microsoft.SharePoint.Portal.SingleSignon.SSOCanaryChecker.b() " error with SetCredentials in a WEB SERVICE (I cant addCanary(Page)).
Can you help me?
Thank you.
Left by Ekon on May 17, 2005 12:31 PM

# SingleSignOn Canary and other wildlife
Requesting Gravatar...
I had a few frustrations trying to get a simple ASP.NET page that saved some users credentials to the...
Left by Dave Gardner on Oct 20, 2005 11:30 PM

# re: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.
Requesting Gravatar...
i have tries to implement the webpart above in order to set the credentials, but it does not work for me, can anyone help?
Left by peter on Mar 16, 2006 8:57 AM

# re: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.
Requesting Gravatar...
Some extra information: the part that goes wrong is the SSOCanaryChecker.AddCanary(Page); in the OnInit event. When i edit this line in the code the webpart cannot be started.
Left by peter on Mar 16, 2006 10:24 AM

# re: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.
Requesting Gravatar...
hi,

when i tyr to create a application definition in a webpart using the code shown below:

Application.AddApplication(
App,
rgFields,
Application.ApplicationCreationDisposition.CreateNew);

i am getting same error:

Microsoft.SharePoint.Portal.SingleSignon.SSOCanaryChecker.b()

Even i have tried to add

SSOCanaryChecker.AddCanary(this.Page);

in createchildcontrol of my webpart.

Please help me, i am fighting for solution for last 2 days.
Thanks in advance

Regards
Sathya
Left by Sathya Narayanan on Apr 07, 2006 2:58 AM

# re: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.
Requesting Gravatar...
Hi Cal and everyone,


I want your web-service that is fine for windows-desktop application. Because I am unable to make that service to get the SSO Credential.

Thanks!
Left by Muhammad Masood on Mar 11, 2007 2:41 PM

# re: (SPS) SSO_E_CANARY_VALIDATION_FAILURE error solved thanks to the help of a very nice guy.
Requesting Gravatar...
Hi

I could not use your code. SSOCanaryChecker.AddCanary(Page) draws an exceprion with message "Request failed". I wrote a simple webpart and put the above code in it. what is wrong with it? the application definition and sharepoint sso configuration is correct.

Left by Srinivas Muvvala on Mar 21, 2007 10:03 AM

Your comment:
 (will show your gravatar)


Copyright © Tariq | Powered by: GeeksWithBlogs.net