/// <summary> /// Displays warning message in "Design mode". /// </summary> /// <param name="message">Message that will be displayed. Default misconfiration message is used when no parameter is given.</param> private bool DisplayMessage(string message = null) { // Error label is displayed in Design mode when LinkedIn is disabled if (PortalContext.IsDesignMode(PortalContext.ViewMode)) { if (String.IsNullOrEmpty(message)) { // Default message informing about misconfiguration is dispalyed. StringBuilder parameter = new StringBuilder(); parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> "); parameter.Append(GetString("settingscategory.cmsmembership") + " -> "); parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> "); parameter.Append(GetString("settingscategory.cmslinkedin")); if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { // Make it link for Admin parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(ApplicationUrlHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">"); parameter.Append("</a>"); } message = String.Format(GetString("mem.linkedin.disabled"), parameter); } lblError.Text = message; lblError.Visible = true; } return(lblError.Visible); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { Visible = false; } else { if (SystemContext.IsFullTrustLevel) { // Check if OpenID module is enabled if (SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSEnableOpenID")) { ltlScript.Text = ScriptHelper.GetIncludeScript(PROVIDERS_LOCATION + "OpenIDSelector.js"); lblError.Text = GetString("openid.invalidid"); SetProviders(); DisplayButtons(); openIDhelper = new CMSOpenIDHelper(); CheckStatus(); } else { // Error label is displayed in Design mode when OpenID is disabled if (PortalContext.IsDesignMode(PortalContext.ViewMode)) { StringBuilder parameter = new StringBuilder(); parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> "); parameter.Append(GetString("settingscategory.cmsmembership") + " -> "); parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> "); parameter.Append(GetString("settingscategory.cmsopenid")); if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { // Make it link for Admin parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(UIContextHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">"); parameter.Append("</a>"); } lblError.Text = String.Format(GetString("mem.openid.disabled"), parameter.ToString()); lblError.Visible = true; txtInput.Visible = false; } else { Visible = false; } } } // Error label is displayed in Design mode when OpenID library is not enabled else { lblError.Text = ResHelper.GetString("socialnetworking.fulltrustrequired"); lblError.Visible = true; txtInput.Visible = false; } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { if (SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSEnableWindowsLiveID")) { plcPasswordNew.Visible = AllowFormsAuthentication; pnlExistingUser.Visible = AllowExistingUser; liveUser = SessionHelper.GetValue("windowsliveloginuser") as WindowsLiveLogin.User; // There is no windows live user object stored in session - hide all if ((liveUser == null) && HideForNoLiveID) { Visible = false; } // WAI validation lblPasswordNew.AssociatedControlClientID = passStrength.InputClientID; } else { // Error label is displayed in Design mode when Windows Live ID is disabled if (PortalContext.IsDesignMode(PortalContext.ViewMode)) { StringBuilder parameter = new StringBuilder(); parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> "); parameter.Append(GetString("settingscategory.cmsmembership") + " -> "); parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> "); parameter.Append(GetString("settingscategory.cmswindowsliveid")); if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { // Make it link for Admin parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(ApplicationUrlHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">"); parameter.Append("</a>"); } lblError.Text = String.Format(GetString("mem.liveid.disabled"), parameter.ToString()); plcError.Visible = true; plcContent.Visible = false; } else { Visible = false; } } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (!StopProcessing) { plcError.Visible = false; // Check if LinkedIn module is enabled if (!LinkedInHelper.LinkedInIsAvailable(SiteContext.CurrentSiteName) && !plcError.Visible) { // Error label is displayed only in Design mode if (PortalContext.IsDesignMode(PortalContext.ViewMode)) { StringBuilder parameter = new StringBuilder(); parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> "); parameter.Append(GetString("settingscategory.cmsmembership") + " -> "); parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> "); parameter.Append(GetString("settingscategory.cmslinkedin")); if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { // Make it link for Admin parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(ApplicationUrlHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">"); parameter.Append("</a>"); } lblError.Text = String.Format(GetString("mem.linkedin.disabled"), parameter); plcError.Visible = true; plcContent.Visible = false; } // In other modes is web part hidden else { Visible = false; } } // Display web part when no error occurred if (!plcError.Visible && Visible) { // Hide web part if user is authenticated if (AuthenticationHelper.IsAuthenticated()) { Visible = false; return; } plcPasswordNew.Visible = AllowFormsAuthentication; pnlExistingUser.Visible = AllowExistingUser; SetLinkedInProfileFromSession(); // There is no LinkedIn profile stored in session - hide all if (mLinkedInProfile == null && HideForNoLinkedInUserID) { Visible = false; } else if (!RequestHelper.IsPostBack()) { LoadData(); } } } else { Visible = false; } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (!StopProcessing) { plcError.Visible = false; // Check if OpenID module is enabled if (!SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSEnableOpenID") && !plcError.Visible) { // Error label is displayed only in Design mode if (PortalContext.IsDesignMode(PortalContext.ViewMode)) { StringBuilder parameter = new StringBuilder(); parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> "); parameter.Append(GetString("settingscategory.cmsmembership") + " -> "); parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> "); parameter.Append(GetString("settingscategory.cmsopenid")); if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { // Make it link for Admin parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(ApplicationUrlHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">"); parameter.Append("</a>"); } lblError.Text = String.Format(GetString("mem.openid.disabled"), parameter.ToString()); plcError.Visible = true; plcContent.Visible = false; } // In other modes is webpart hidden else { Visible = false; } } // Display webpart when no error occured if (!plcError.Visible && Visible) { if (!AuthenticationHelper.IsAuthenticated()) { plcPasswordNew.Visible = AllowFormsAuthentication; pnlExistingUser.Visible = AllowExistingUser; // Initialize OpenID session response = (Dictionary <string, object>)SessionHelper.GetValue(SESSION_NAME_USERDATA); userProviderUrl = ValidationHelper.GetString(SessionHelper.GetValue(SESSION_NAME_URL), null); // Check that OpenID is not already registered if (response != null) { UserInfo ui = OpenIDUserInfoProvider.GetUserInfoByOpenID((string)response["ClaimedIdentifier"]); // OpenID is already registered to some user if (ui != null) { plcContent.Visible = false; plcError.Visible = true; lblError.Text = GetString("mem.openid.openidregistered"); } } // There is no OpenID response object stored in session - hide all if (response == null) { if (HideForNoOpenID) { Visible = false; } } else if (!RequestHelper.IsPostBack()) { LoadData(); } } // Hide webpart for authenticated users else { Visible = false; } } } // Hide control when StopProcessing = TRUE else { Visible = false; } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { if (SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSEnableWindowsLiveID")) { string siteName = SiteContext.CurrentSiteName; if (!string.IsNullOrEmpty(siteName)) { // Get LiveID settings string appId = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSApplicationID"); string secret = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSApplicationSecret"); if (!WindowsLiveLogin.UseServerSideAuthorization) { // Add windows live ID script ScriptHelper.RegisterClientScriptInclude(Page, typeof(string), "WLScript", LIVE_CONNECT_API_URL); // Add login functions String loginLiveIDClientScript = @" function signUserIn() { var scopesArr = ['wl.signin']; WL.login({ scope: scopesArr }); } function refreshLiveID(param) { " + ControlsHelper.GetPostBackEventReference(btnHidden, "#").Replace("'#'", "param") + @" } "; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ClientInitLiveIDScript", ScriptHelper.GetScript(loginLiveIDClientScript)); } // Check valid Windows LiveID parameters if ((appId == string.Empty) || (secret == string.Empty)) { lblError.Visible = true; lblError.Text = GetString("liveid.incorrectsettings"); return; } WindowsLiveLogin wll = new WindowsLiveLogin(appId, secret); // If user is already authenticated if (AuthenticationHelper.IsAuthenticated()) { // If signout should be visible and user has LiveID registered if (ShowSignOut && !String.IsNullOrEmpty(MembershipContext.AuthenticatedUser.UserSettings.WindowsLiveID)) { // Get data from auth cookie string[] userData = AuthenticationHelper.GetUserDataFromAuthCookie(); // Check if user has truly logged in by LiveID if ((userData != null) && (Array.IndexOf(userData, "liveidlogin") >= 0)) { // Redirect to Windows Live and back to "home" page string defaultAliasPath = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSDefaultAliasPath"); string url = DocumentURLProvider.GetUrl(defaultAliasPath); string navUrl = wll.GetLogoutUrl(URLHelper.GetAbsoluteUrl(url)); // If text is set use text/button link if (!string.IsNullOrEmpty(SignOutText)) { // Button link if (ShowAsButton) { btnSignOut.CommandArgument = navUrl; btnSignOut.Text = SignOutText; btnSignOut.Visible = true; } // Text link else { btnSignOutLink.CommandArgument = navUrl; btnSignOutLink.Text = SignOutText; btnSignOutLink.Visible = true; } } // Image link else { btnSignOutImage.CommandArgument = navUrl; btnSignOutImage.ImageUrl = ResolveUrl(SignOutImageURL); btnSignOutImage.Visible = true; btnSignOut.Text = GetString("webparts_membership_signoutbutton.signout"); } } } else { Visible = false; } } // Sign In else { // Create return URL string returnUrl = QueryHelper.GetText("returnurl", ""); returnUrl = (returnUrl == String.Empty) ? RequestContext.CurrentURL : returnUrl; // Create parameters for LiveID request URL String[] parameters = new String[3]; parameters[0] = returnUrl; parameters[1] = TrackConversionName; parameters[2] = ConversionValue.ToString(); SessionHelper.SetValue("LiveIDInformtion", parameters); returnUrl = wll.GetLoginUrl(); // Get App ID appId = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSApplicationID"); // Create full LiveID request URL string navUrl = AUTHORIZATION_URL + "?client_id=" + appId + "&redirect=true&scope=wl.signin&response_type=code&redirect_uri=" + HttpUtility.UrlEncode(returnUrl); // If text is set use text/button link if (!string.IsNullOrEmpty(SignInText)) { // Button link if (ShowAsButton) { AssignButtonControl(navUrl, returnUrl, appId); btnSignIn.Text = SignInText; } // Text link else { AssignHyperlinkControl(navUrl, returnUrl, appId); lnkSignIn.Text = SignInText; } } // Image link else { AssignHyperlinkControl(navUrl, returnUrl, appId); lnkSignIn.ImageUrl = ResolveUrl(SignInImageURL); lnkSignIn.Text = GetString("webparts_membership_signoutbutton.signin"); } } } } else { // Error label is displayed in Design mode when Windows Live ID is disabled if (PortalContext.IsDesignMode(PortalContext.ViewMode)) { StringBuilder parameter = new StringBuilder(); parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> "); parameter.Append(GetString("settingscategory.cmsmembership") + " -> "); parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> "); parameter.Append(GetString("settingscategory.cmswindowsliveid")); if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { // Make it link for Admin parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(UIContextHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">"); parameter.Append("</a>"); } lblError.Text = String.Format(GetString("mem.liveid.disabled"), parameter); lblError.Visible = true; } else { Visible = false; } } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (!StopProcessing) { plcError.Visible = false; // Check renamed DLL library if (!SystemContext.IsFullTrustLevel) { // Error label is displayed when OpenID library is not enabled lblError.ResourceString = "socialnetworking.fulltrustrequired"; plcError.Visible = true; plcContent.Visible = false; } // Check if LinkedIn module is enabled if (!LinkedInHelper.LinkedInIsAvailable(SiteContext.CurrentSiteName) && !plcError.Visible) { // Error label is displayed only in Design mode if (PortalContext.IsDesignMode(PortalContext.ViewMode)) { StringBuilder parameter = new StringBuilder(); parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> "); parameter.Append(GetString("settingscategory.cmsmembership") + " -> "); parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> "); parameter.Append(GetString("settingscategory.cmslinkedin")); if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { // Make it link for Admin parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(UIContextHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">"); parameter.Append("</a>"); } lblError.Text = String.Format(GetString("mem.linkedin.disabled"), parameter); plcError.Visible = true; plcContent.Visible = false; } // In other modes is web part hidden else { Visible = false; } } // Display web part when no error occurred if (!plcError.Visible && Visible) { // Hide web part if user is authenticated if (AuthenticationHelper.IsAuthenticated()) { Visible = false; return; } plcPasswordNew.Visible = AllowFormsAuthentication; pnlExistingUser.Visible = AllowExistingUser; // Load LinkedIn data from session linkedInHelper = new LinkedInHelper(); string linkedInData = ValidationHelper.GetString(SessionHelper.GetValue(SESSION_NAME_USERDATA), string.Empty); if (!string.IsNullOrEmpty(linkedInData)) { var doc = new XmlDocument(); doc.LoadXml(linkedInData); linkedInHelper.Initialize(doc); } // There is no LinkedIn user ID stored in session - hide all if (string.IsNullOrEmpty(linkedInHelper.MemberId) && HideForNoLinkedInUserID) { Visible = false; } else if (!RequestHelper.IsPostBack()) { LoadData(); } } } else { Visible = false; } }