From: <m_h...@us...> - 2006-07-25 22:09:47
|
Revision: 220 Author: m_hildebrand Date: 2006-07-25 14:44:20 -0700 (Tue, 25 Jul 2006) ViewCVS: http://svn.sourceforge.net/tcdb/?rev=220&view=rev Log Message: ----------- User can now sync against AD properly Modified Paths: -------------- Website/App_Code/AD_Authentication.cs Website/App_Code/SiteMaster.cs Website/App_Code/Users.cs Website/Includes/Authenticate.ascx.cs Website/Includes/UserSettings.ascx Website/Includes/UserSettings.ascx.cs Modified: Website/App_Code/AD_Authentication.cs =================================================================== --- Website/App_Code/AD_Authentication.cs 2006-07-25 21:15:20 UTC (rev 219) +++ Website/App_Code/AD_Authentication.cs 2006-07-25 21:44:20 UTC (rev 220) @@ -60,6 +60,8 @@ string strDomain = ConfigDB.GetConfigString("ad_domain"); m_logg.Debug("Getting AD information for [" + strUserName + "] in domain [" + strDomain + "]"); + //DirectoryEntry de = new DirectoryEntry("LDAP://" + strDomain); + //de.AuthenticationType = AuthenticationTypes.Anonymous; DirectoryEntry de = new DirectoryEntry("LDAP://" + strDomain, strUserName, strPassword); DirectorySearcher ds = new DirectorySearcher(de); Modified: Website/App_Code/SiteMaster.cs =================================================================== --- Website/App_Code/SiteMaster.cs 2006-07-25 21:15:20 UTC (rev 219) +++ Website/App_Code/SiteMaster.cs 2006-07-25 21:44:20 UTC (rev 220) @@ -53,17 +53,20 @@ try { m_logg.Debug("Pulling the userID from the session data"); - id = (int)Session["m_user"]; - m_logg.Debug("Found userID [" + id.ToString() + "]"); + //id = (int)Session["m_user"]; + m_user = (User)Session["m_user"]; + //m_logg.Debug("Found userID [" + id.ToString() + "]"); + m_logg.Debug("Found user [" + m_user.ToString() + "]"); } catch { m_logg.Debug("Unable to find user object in session data, using the anonymous user instead"); - id = Constants.ANONYMOUSUSERID; + //id = Constants.ANONYMOUSUSERID; + m_user = UserDB.GetUserInfo(Constants.ANONYMOUSUSERID); } - m_logg.Debug("Setting up a user object based on userID [" + id.ToString() + "]"); - m_user = UserDB.GetUserInfo(id); + //m_logg.Debug("Setting up a user object based on userID [" + id.ToString() + "]"); + //m_user = UserDB.GetUserInfo(id); m_logg.Debug("Got information for user [" + m_user.ToString() + "]"); if (m_user.ID != Constants.ANONYMOUSUSERID) @@ -76,7 +79,12 @@ m_logg.Debug("User [" + m_user.ToString() + "] is anonymous, marking as guest"); m_user.ISAUTHENTICATED = false; } - + /* try + { + User g_user; + g_user = (User)Session["g_user"]; + } + catch { }*/ return m_user; } } Modified: Website/App_Code/Users.cs =================================================================== --- Website/App_Code/Users.cs 2006-07-25 21:15:20 UTC (rev 219) +++ Website/App_Code/Users.cs 2006-07-25 21:44:20 UTC (rev 220) @@ -232,6 +232,7 @@ private bool p_automation; private bool p_isAuthenticated; private bool p_isNew; + private string p_password; private List<Assignment> p_assignments; /* TODO: Implement these as the time is right private List<Feature> p_features; @@ -272,6 +273,7 @@ p_isAuthenticated = false; p_isNew = false; p_assignments = null; + p_password = ""; } private void BuildUser(User user) @@ -287,6 +289,7 @@ p_automation = user.AUTOMATION; p_isAuthenticated = user.ISAUTHENTICATED; p_isNew = false; + p_password = ""; // TODO: Figure out why the following line caused an infinite loop // Problem: I think that it was caused because creating an anon user calls this, // which in turn creates an anon user. @@ -371,6 +374,12 @@ set { p_isNew = value; } } + public string PASSWORD + { + get { return p_password; } + set { p_password = value; } + } + public override string ToString() { return p_username.Trim(); Modified: Website/Includes/Authenticate.ascx.cs =================================================================== --- Website/Includes/Authenticate.ascx.cs 2006-07-25 21:15:20 UTC (rev 219) +++ Website/Includes/Authenticate.ascx.cs 2006-07-25 21:44:20 UTC (rev 220) @@ -38,11 +38,13 @@ m_logg.Debug("The user just authenticated is [" + myUser.FULLNAME + "]"); - // If we're not dealing with an anonymous user, set the state variable + // If we're not dealing with an anonymous user, set the state variable and password if (myUser.ID != Constants.ANONYMOUSUSERID) { m_logg.Info("Login for " + myUser.ToString() + " was successful, setting session variable"); - Session["m_user"] = myUser.ID; + myUser.PASSWORD = LoginUser.Password; + //Session["m_user"] = myUser.ID; + Session["m_user"] = myUser; } if (myUser.ISNEW) @@ -98,7 +100,8 @@ { m_logg.Debug("Setting authentication cookie and redirecting to requested page"); // We have a valid user who is already in the DB - Session["m_user"] = myUser.ID; + //Session["m_user"] = myUser.ID; + Session["m_user"] = myUser; FormsAuthentication.SetAuthCookie(LoginUser.UserName, LoginUser.RememberMeSet); // TODO: The default redirect should be pulled from the DB @@ -142,7 +145,8 @@ { m_logg.Debug("User successfully saved to DB"); newUser = UserDB.GetUserInfo(newUser.USERNAME); - Session["m_user"] = newUser.ID; + //Session["m_user"] = newUser.ID; + Session["m_user"] = newUser; // TODO: Lookup the admin/lead for the selected product m_logg.Debug("Looking up admin/lead for product [" + product.ToString() + "]"); Modified: Website/Includes/UserSettings.ascx =================================================================== --- Website/Includes/UserSettings.ascx 2006-07-25 21:15:20 UTC (rev 219) +++ Website/Includes/UserSettings.ascx 2006-07-25 21:44:20 UTC (rev 220) @@ -119,7 +119,11 @@ <label> Name: </label> - <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("fullName") %>'></asp:Label> + <asp:TextBox ID="firstNameBox" runat="server" Text='<%# Eval("firstName") %>'></asp:TextBox> + <asp:TextBox ID="lastNameBox" runat="server" Text='<%# Eval("lastName") %>'></asp:TextBox> + <!-- + <asp:Label ID="FirstNameLabel" runat="server" Text='<%# Eval("firstName") %>'></asp:Label> + <asp:Label ID="LastNameLabel" runat="server" Text='<%# Eval("lastName") %>'></asp:Label>--> </div> <div class="item"> <label> Modified: Website/Includes/UserSettings.ascx.cs =================================================================== --- Website/Includes/UserSettings.ascx.cs 2006-07-25 21:15:20 UTC (rev 219) +++ Website/Includes/UserSettings.ascx.cs 2006-07-25 21:44:20 UTC (rev 220) @@ -39,6 +39,7 @@ if (mode == "new") FormView1.ChangeMode(FormViewMode.Insert); } + protected void deleteButton_Load(object sender, EventArgs e) { if (mode == "read") @@ -47,6 +48,7 @@ deleteButton.Visible = false; } } + protected void newButton_Load(object sender, EventArgs e) { if (mode == "read") @@ -55,6 +57,7 @@ deleteButton.Visible = false; } } + protected void deleteLabel_Load(object sender, EventArgs e) { if (mode == "read") @@ -63,6 +66,7 @@ deleteLabel.Visible = false; } } + protected void newLabel_Load(object sender, EventArgs e) { if (mode == "read") @@ -71,16 +75,19 @@ deleteLabel.Visible = false; } } + protected void FormView1_ItemDeleted(object sender, FormViewDeletedEventArgs e) { // Can only delete in Adminstration mode Response.Redirect("Administration.aspx"); } + protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e) { if (FormView1.CurrentMode == FormViewMode.Insert && e.CommandName=="Cancel") Response.Redirect("Administration.aspx"); } + protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e) { if (e.Exception == null) @@ -93,6 +100,7 @@ Response.Redirect("UserSettings.aspx?" + Constants.CODE_USER + "=" + userID); } } + protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e) { updateRoles(); @@ -101,9 +109,11 @@ else Response.Redirect("UserSettings.aspx?" + Constants.CODE_USER + "=" + userID); } + protected void updateRoles() { } + protected void SyncWithAD(object sender, CommandEventArgs e) { String username = ""; @@ -112,25 +122,26 @@ else username = ((TextBox)FormView1.FindControl("usernameBox")).Text; - User curUser = AD_Authentication.AD_GetUserInfo(m_user.USERNAME, null, username); + User curUser = AD_Authentication.AD_GetUserInfo(m_user.USERNAME, m_user.PASSWORD, username); if (curUser.ID != -1) { - TextBox firstName = (TextBox)FormView1.FindControl("firstNameBox"); - TextBox lastName = (TextBox)FormView1.FindControl("lastNameBox"); - TextBox email = (TextBox)FormView1.FindControl("emailBox"); - TextBox officePhone = (TextBox)FormView1.FindControl("officePhoneBox"); - TextBox homePhone = (TextBox)FormView1.FindControl("homePhoneBox"); - TextBox cellPhone = (TextBox)FormView1.FindControl("cellPhoneBox"); + TextBox tbx_firstName = (TextBox)FormView1.FindControl("firstNameBox"); + TextBox tbx_lastName = (TextBox)FormView1.FindControl("lastNameBox"); + TextBox tbx_email = (TextBox)FormView1.FindControl("emailBox"); + TextBox tbx_officePhone = (TextBox)FormView1.FindControl("officePhoneBox"); + TextBox tbx_homePhone = (TextBox)FormView1.FindControl("homePhoneBox"); + TextBox tbx_cellPhone = (TextBox)FormView1.FindControl("cellPhoneBox"); - firstName.Text = curUser.FIRSTNAME; - lastName.Text = curUser.LASTNAME; - email.Text = curUser.EMAIL; - officePhone.Text = curUser.OFFICEPHONE; - homePhone.Text = curUser.HOMEPHONE; - cellPhone.Text = curUser.CELLPHONE; + tbx_firstName.Text = curUser.FIRSTNAME; + tbx_lastName.Text = curUser.LASTNAME; + tbx_email.Text = curUser.EMAIL; + tbx_officePhone.Text = curUser.OFFICEPHONE; + tbx_homePhone.Text = curUser.HOMEPHONE; + tbx_cellPhone.Text = curUser.CELLPHONE; } } + protected void editConfig(object sender, CommandEventArgs e) { if (mode == "read") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |