16.01.2013 Views

Microsoft Sharepoint Products and Technologies Resource Kit eBook

Microsoft Sharepoint Products and Technologies Resource Kit eBook

Microsoft Sharepoint Products and Technologies Resource Kit eBook

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

718 Part VIII: Securing SharePoint <strong>Products</strong> <strong>and</strong> <strong>Technologies</strong><br />

3. After the URL for the logon form has been retrieved, redirect the browser to<br />

this URL. The logon form is created by the SSOSrv service. It prompts the user<br />

to enter credentials for the enterprise application in a number of fields. The<br />

order, the number <strong>and</strong> the display names for these fields are configured within<br />

the application definition under Logon Account Information. For example, if<br />

the enterprise application uses user name <strong>and</strong> password for authentication,<br />

two fields will be present in the logon form. For SAP, you may need five fields.<br />

After the SSOSrv service saves the credentials, the form redirects control back<br />

to the original Web Part.<br />

The code in your Web Part will be similar to the following example that shows<br />

how to redirect the user to the logon form to save credentials for an enterprise application<br />

called SampleApp:<br />

protected override void RenderWebPart(HtmlTextWriter writer) //RenderWebPart<br />

{<br />

string[] rgGetCredentialData = null;<br />

try<br />

{<br />

//Try to get the credentials for this application.<br />

//Before running this code, make sure that an individual<br />

//application definition for application called "SampleApp"<br />

//has been added.<br />

Credentials.GetCredentials(1,"SampleAPP", ref rgGetCredentialData);<br />

}<br />

catch (SingleSignonException ssoe)<br />

{<br />

//This exception will be thrown if this user does not have<br />

//credentials for the "SampleApp" application.<br />

if(SSOReturnCodes.SSO_E_CREDS_NOT_FOUND == ssoe.LastErrorCode)<br />

{<br />

//Send the user to the single sign-on logon form.<br />

//The logon form will:<br />

//- Prompt the user for credentials for this application<br />

//- Save credentials for this user for this application<br />

//- Then redirect the user back to this Web Part<br />

string strSSOLogonFormUrl = SingleSignonLocator.GetCredentialEntryUrl<br />

("MyIndividualApplicationID");<br />

writer.Write("Click here to save your<br />

credentials for the Enterprise Application.");<br />

writer.WriteLine();<br />

}<br />

}<br />

}<br />

After the user credentials for the enterprise application have been stored in the<br />

single sign-on database, the custom code in the Web Part should retrieve the credentials<br />

using GetCredentials method, then submit them to the enterprise application in<br />

a manner that is relevant to this application, then retrieve the necessary data from<br />

this application, <strong>and</strong> then finally render the data in the Web Part. Referring back to<br />

Figure 26-1 that shows eight steps described in the section “How Single Sign-On

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!