Esempio n. 1
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            //Put user code to initialize the page here
            try
            {
                // Obtain PortalSettings from Current Context
                AuthenticationController objAuthenticationController = new AuthenticationController();

                // Reset config
                Configuration.ResetConfig();
                Configuration config = Configuration.GetConfig();

                if (UserInfo.Username.IndexOf("\\") > 0)
                {
                    string strDomain = GetUserDomainName(UserInfo.Username);
                    if (strDomain.ToLower() == Request.ServerVariables["SERVER_NAME"].ToLower())
                    {
                        DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, string.Format(Localization.GetString("SameDomainError", this.LocalResourceFile), strDomain, HttpUtility.HtmlEncode(Request.ServerVariables["SERVER_NAME"])), ModuleMessageType.YellowWarning);
                        DisableScreen();
                        return;
                    }
                }

                if (!Page.IsPostBack)
                {
                    ProviderConfiguration objProviderConfiguration = ProviderConfiguration.GetProviderConfiguration(Configuration.AUTHENTICATION_KEY);

                    chkAuthentication.Checked      = config.WindowsAuthentication;
                    chkSynchronizeRole.Checked     = config.SynchronizeRole;
                    chkSynchronizePassword.Checked = config.SynchronizePassword;
                    txtRootDomain.Text             = config.RootDomain;
                    txtUserName.Text    = config.UserName;
                    txtEmailDomain.Text = config.EmailDomain;

                    // Bind Authentication provider list, this allows each portal could use different provider for authentication
                    foreach (object _Provider in objProviderConfiguration.Providers)
                    {
                        DictionaryEntry objProvider  = (DictionaryEntry)_Provider;
                        string          ProviderName = Convert.ToString(objProvider.Key);
                        string          ProviderType = ((Provider)objProvider.Value).Type;

                        this.cboProviders.Items.Add(new ListItem(ProviderName, ProviderType));
                    }

                    // Bind AuthenticationTypes list, on first configure, it could obtains only from default authentication provider
                    try
                    {
                        this.cboAuthenticationType.DataSource = objAuthenticationController.AuthenticationTypes();
                    }
                    catch (TypeInitializationException)
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("AuthProviderError", this.LocalResourceFile), ModuleMessageType.YellowWarning);
                        DisableScreen();
                        return;
                    }
                    this.cboAuthenticationType.DataBind();
                    this.cboAuthenticationType.Items.FindByText(config.AuthenticationType).Selected = true;
                }

                valConfirm.ErrorMessage = Localization.GetString("PasswordMatchFailure", this.LocalResourceFile);
            }
            catch (Exception exc)             //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }