by
0
6
1,156
0
Top 1% !
Popular
Famous
Easy-to-find
Specified
OpenSource
Popularity: 25398th place

Published on:

LanguageCSharp
LicenseMIT_X11
OSWindows

Main: Configures the ACS service namespace with the proper objects for this sample.

<summary>
Configures the ACS service namespace with the proper objects for this sample.
</summary>
<remarks>
Existing objects that are needed for this sample will be deleted and recreated.
</remarks>
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/294201/Main--Configures-the-ACS-service-namespa?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
using System; using System.Linq; using System.Data.Services.Client; using System.Globalization; using ACS.Management; using Common.ACS.Management; /// <summary> /// Configures the ACS service namespace with the proper objects for this sample. /// </summary> /// <remarks> /// Existing objects that are needed for this sample will be deleted and recreated. /// </remarks> static void Main(string[] args) { const string rpName = "ASPNET MVC3 Custom Sign-In Page Sample"; const string rpRealm = "http://localhost:64000/"; const string rpReplyTo = "http://localhost:64000/Account/SignIn"; const string facebookName = "Facebook"; const string yahooName = "Yahoo!"; const string defaultRuleGroupName = "Default rule group for ASPNET MVC3 Custom Sign-In Page Sample"; // Please update these with your own Facebook application information const string applicationId = "applicationid"; const string applicationSecret = "applicationsecret"; string facebookIdpName = String.Format(CultureInfo.InvariantCulture, "Facebook-{0}", applicationId); ManagementService svc = ManagementServiceHelper.CreateManagementServiceClient(); // // Clean up pre-existing configuration // svc.DeleteRelyingPartyByRealmIfExists(rpRealm); svc.DeleteRuleGroupByNameIfExists(defaultRuleGroupName); svc.DeleteIdentityProviderIfExists(facebookIdpName); svc.DeleteIdentityProviderIfExists(yahooName); svc.SaveChangesBatch(); // // Create Identity Providers // IdentityProvider live = svc.GetIdentityProviderByName("uri:WindowsLiveID");; IdentityProvider facebook = svc.CreateFacebookIdentityProvider(applicationId, applicationSecret, "email,user_events"); SetSignInInformation(svc, facebook, facebookName); IdentityProvider yahoo = svc.CreateOpenIdIdentityProvider(yahooName, "https://open.login.yahooapis.com/openid/op/auth"); SetSignInInformation(svc, yahoo, yahooName); IdentityProvider[] associatedProviders = new[] { live, facebook, yahoo }; // // Create Relying Party // RelyingParty relyingParty = svc.CreateRelyingParty(rpName, rpRealm, rpReplyTo, RelyingPartyTokenType.SAML_2_0, false); svc.AssociateIdentityProvidersWithRelyingParties(associatedProviders, new[] { relyingParty }); RuleGroup ruleGroup = svc.CreateRuleGroup(defaultRuleGroupName); svc.AssignRuleGroupToRelyingParty(ruleGroup, relyingParty); // // Create simple rules to pass through all claims from each issuer. // foreach (IdentityProvider identityProvider in associatedProviders) { string ruleDescription = string.Format(CultureInfo.InvariantCulture, "Pass through all claims from '{0}'", identityProvider.Issuer.Name); svc.CreateRule(identityProvider.Issuer, null, null, null, null, ruleGroup, ruleDescription); } svc.SaveChangesBatch(); Console.WriteLine("Sample successfully configured. Press ENTER to continue ..."); Console.ReadLine(); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus