Direct selected users to edit page
I need help for the code below. This page display the user info based on their windows authentication user ID. It is working fine and I need that. Then it is also letting admin to edit anybodys profileâ¦which is working fine too. Now I have created a table name UserCheck with username and editusername fields (just 2 fields). Now I want to link the table in this page where user can edit other user profile based on the username authorization in the table UserCheckâ¦..Check if username is allowed to change editusernameâ¦if yes then direct to edit page else take him back to the main pageâ¦
Connection string is already built up in webconfig fileâ¦all I need to put connection to the table in this codeâ¦â¦plz help and let me know if you didnât understand anythingâ¦.
protected void Page_Load(object sender, System.EventArgs e)
{
string strUser,theUser,userToEdit,url;
int startPos;
strUser=System.Security.Principal.WindowsIdentity. GetCurrent().Name.ToString();
startPos=strUser.IndexOf('\\')+1;
theUser=strUser.Substring(startPos);
Session["username"]=theUser;
Session["usernameToEdit"]=Request.QueryString["username"];
//if the admin is Sadia then she could edit anybody's profile.
if(theUser!="ssh001111")
{
Session["usernameToEdit"]=Session["username"].ToString();
}
//Checking to see if the user is present in the database
SPAHPUser fsUser = new SPAHPUser();
if(fsUser.UserExists(theUser)==1)
{
url="../Edit/EditUserDetails.aspx?action=edit&username="+Sessio n["usernameToEdit"].ToString();
Response.Redirect(url);
}
else //The user is new and he needs to be added into the database
{
userNotFoundPanel.Visible=true;
url="the user is new";
}
TextBox1.Text=url;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
}
}
Sadia Shoiab
|