From: <ro...@us...> - 2006-07-28 22:16:13
|
Revision: 235 Author: rouquin Date: 2006-07-28 15:15:58 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/tcdb/?rev=235&view=rev Log Message: ----------- Added password prompt for when password is lost between sessions. Modified Paths: -------------- Website/Includes/UserSettings.ascx Website/Includes/UserSettings.ascx.cs Modified: Website/Includes/UserSettings.ascx =================================================================== --- Website/Includes/UserSettings.ascx 2006-07-28 21:19:34 UTC (rev 234) +++ Website/Includes/UserSettings.ascx 2006-07-28 22:15:58 UTC (rev 235) @@ -4,13 +4,14 @@ <%@ Register Assembly="eWorld.UI, Version=2.0.0.2148, Culture=neutral, PublicKeyToken=24d65337282035f2" Namespace="eWorld.UI" TagPrefix="ew" %> <div id="UserSettings"> - <asp:FormView ID="UserSettingsView" runat="server" DataSourceID="UserDataSource" DataKeyNames="userID" - OnItemDeleted="UserSettingsView_ItemDeleted" OnItemCommand="UserSettingsView_ItemCommand" OnItemInserted="UserSettingsView_ItemInserted" - OnItemUpdated="UserSettingsView_ItemUpdated" OnDataBound="UserSettingsView_DataBound"> + <asp:FormView ID="UserSettingsView" runat="server" DataSourceID="UserDataSource" + DataKeyNames="userID" OnItemDeleted="UserSettingsView_ItemDeleted" OnItemCommand="UserSettingsView_ItemCommand" + OnItemInserted="UserSettingsView_ItemInserted" OnItemUpdated="UserSettingsView_ItemUpdated" + OnDataBound="UserSettingsView_DataBound"> <HeaderTemplate> <div class="ch"> <h2> - <asp:Label runat="server" ID="userSettingsTitle" Text="User Settings" /></h2> + <asp:Label runat="server" ID="userSettingsTitle" Text="User Settings" /></h2> <div class="bottom"> </div> </div> @@ -170,10 +171,10 @@ <div class="left"> <div class="item"> <asp:TreeView ID="roleTree" runat="server" OnInit="roleTreeEdit_Init" OnTreeNodePopulate="roleTree_TreeNodePopulate" - ShowCheckBoxes="All" OnSelectedNodeChanged="roleTree_SelectedNodeChanged" > + ShowCheckBoxes="All" OnSelectedNodeChanged="roleTree_SelectedNodeChanged"> <Nodes> <asp:TreeNode SelectAction="SelectExpand" Text="<label>Roles</label>" - Value="Roles" PopulateOnDemand="True" ShowCheckBox="false" /> + Value="Roles" PopulateOnDemand="True" ShowCheckBox="false" /> </Nodes> </asp:TreeView> </div> @@ -191,6 +192,9 @@ <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> | <asp:LinkButton ID="sync" runat="server" Text="Sync with AD" OnCommand="SyncWithAD" /> + + <asp:Label ID="passwordLbl" runat="server" Text="Password: "></asp:Label><asp:TextBox + ID="passwordBox" runat="server" TextMode="Password"></asp:TextBox> </div> <div class="right"> </div> @@ -201,6 +205,7 @@ <b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"> </b></b> </div> + <asp:Label ID="errorLbl" runat="server"></asp:Label> </EditItemTemplate> <InsertItemTemplate> <div class="xsnazzy"> @@ -288,6 +293,9 @@ <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> | <asp:LinkButton ID="sync" runat="server" Text="Sync with AD" OnCommand="SyncWithAD" /> + + <asp:Label ID="passwordLbl" runat="server" Text="Password: "></asp:Label><asp:TextBox + ID="passwordBox" runat="server" TextMode="Password"></asp:TextBox> </div> <div class="right"> </div> @@ -298,6 +306,7 @@ <b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"> </b></b> </div> + <asp:Label ID="errorLbl" runat="server"></asp:Label> </InsertItemTemplate> </asp:FormView> Modified: Website/Includes/UserSettings.ascx.cs =================================================================== --- Website/Includes/UserSettings.ascx.cs 2006-07-28 21:19:34 UTC (rev 234) +++ Website/Includes/UserSettings.ascx.cs 2006-07-28 22:15:58 UTC (rev 235) @@ -118,14 +118,33 @@ protected void SyncWithAD(object sender, CommandEventArgs e) { - // TODO: If m_user.PASSWORD is "" or null, we must prompt for a password somehow - // or the AD authentication will fail + TextBox passwordBox = (TextBox)UserSettingsView.FindControl("passwordBox"); + String username = ((TextBox)UserSettingsView.FindControl("usernameBox")).Text; + if (username == "") + { + Label errorLbl = (Label)UserSettingsView.FindControl("errorLbl"); + + m_logg.Info("Could not sync with AD. No username specified"); + errorLbl.Text = "<font color=red>Please provide username to search for.</font>"; + return; + } + String password = null; if (m_user.PASSWORD != "") password = m_user.PASSWORD; + else if (passwordBox.Text != "") + password = passwordBox.Text; + else + { + Label errorLbl = (Label)UserSettingsView.FindControl("errorLbl"); + + m_logg.Info("Could not sync with AD. No password provided."); + errorLbl.Text = "<font color=red>Please provide password to authenticate with AD</font>"; + return; + } + User curUser = AD_Authentication.AD_GetUserInfo(m_user.USERNAME, password, username); - if (curUser.ID != -1) { TextBox tbx_firstName = (TextBox)UserSettingsView.FindControl("firstNameBox"); @@ -162,6 +181,22 @@ username.Enabled = false; } } + if (UserSettingsView.CurrentMode != FormViewMode.ReadOnly) + { + Label passwordLbl = (Label)UserSettingsView.FindControl("passwordLbl"); + TextBox passwordBox = (TextBox) UserSettingsView.FindControl("passwordBox"); + + if (m_user.PASSWORD != "") + { + passwordBox.Visible = false; + passwordLbl.Visible = false; + } + else + { + passwordBox.Visible = true; + passwordLbl.Visible = true; + } + } } protected void roleTreeView_Init(object sender, EventArgs e) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |