How are you supposed to manage users? I see the User_Edit.aspx page but it is not even part of the MaterPage and it does not receive the username when you try to run it.
In the TimeTracker\Web.config file what is the user account type setting for ActiveDirectory. I saw no changes when I changed it to numbers or the string values of the other choices.
Each Tab at the top of the page is show as a link but does not go anywhere? Any reason?
Other than those it looks nice. Is this project something that is still under construction?
Sorry for all the questions and thanks in advance for answers...
Nice article. I am sorry it seems I forgot to let everyone know I am an amature at ASP.NET 2.0 programming. Stepping into this already deveoped starter kit and applying this membership role manager is too much for me at this time...hehe. I nuderstand the
concept but I cannot seem to put it together with the code in the Starter Kit. It seems that the Database included with the Starter Kit has Stored Procedures to do just about everything with users. there just is not (as you say) Presentation layer that uses
those procedures. if anyone has already made this feature work I would be glad if you would lead me in the right direction.
Have you gotten anywhere with this? I'm in the same boat as you. I have the starter kit up and running but need to edit/delete users and can't figure it out.
I am using the membership and roles provider and all the aspnet databases were generated by the regsql script suggested above.
What I am running into is:
when I click "delete account" button, it calls Membership.Deleteuser(user) which on the surface appears to delete the user. However, it is only removing them from the aspnet_membership table and not the aspnet_users table. If they are assigned no roles, it
will delete them properly. If I assign a role to a new account, it shows up twice in my dropdown list (does it see it as a whole different account with same username but different roles info???)
I have a dropdown list that lets you choose between the differing names in the aspnet_users table.
Looking at the aspnet_users_deleteuser stored procedure (which is what is called by membership.deleteuser(right??)) I would like to try to modify it to accept differing parameters.
If you look at my table data, two accounts called "test" have totally seperate applicationName guid's and one is an "admin" the other is not. Calling delete user will take out one of the two, but not the one with admin priviledges.
What has everyone else done here? I have to be completely missing a critical step. Without immersing myself in how these tables handle membership, I'd like to find a quick workaround for this site that I have due friday.
Here is my current code. It deletes from the aspnet_membership, but not the users table.
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="removeuser.aspx.vb" Inherits="_Default" title="Untitled Page" %>
<%@ Import Namespace="System.Web.Security" %>
<%--<asp:Content ID="Content1" ContentPlaceHolderID="header" Runat="Server">
</asp:Content>--%>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<center>
<h3>Delete User</h3>
<div id="delete">
<asp:Label id="Msg" ForeColor="maroon" runat="server" /><br />
<asp:DropDownList runat="server" DataTextField="username" EnableViewState="true" DataValueField="username" ID="ddlUsers" AutoPostBack="true" />
<p style="color:red"><asp:label ID="lblconfirm" runat="server" Visible="false" Text="Are you sure you want to delete this account?"/>
</p>
<br />
<asp:Button id="YesButton" Text="Yes" OnClick="YesButton_OnClick" runat="server" />
<asp:Button id="CancelButton" Text="Cancel" OnClick="CancelButton_OnClick" runat="server" />
</div>
<asp:Label ID="lblmessage" Text="You must log in before you can delete your account" Visible="false" runat="server" />
</center>
</asp:Content>
<------------------------------------------------------------------>
Imports System.Data.sqlclient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack() Then
loadddldata()
isloggedin()
End If
If IsPostBack() Then
lblconfirm.Visible = "true"
End If
End Sub
Public Sub loadddldata()
'build select statement
Dim sql As String = "Select UserName from aspnet_users"
'pull in connection string from web.config
Dim sqlConn As New Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("poloconnection").ToString())
'create new sql command
Dim sqlCom As New Data.SqlClient.SqlCommand(sql, sqlConn)
Try
'tells that we will use T-sql text instead of Stor. Proc, etc
sqlCom.CommandType = Data.CommandType.Text
'listens for an open dataconnection, and if its not there then it
'opens one.
If sqlConn.State = Data.ConnectionState.Open Then
sqlCom.ExecuteNonQuery()
Else
sqlConn.Open()
sqlCom.ExecuteNonQuery()
End If
'add a dataadapter to process sql command
Dim da As New Data.SqlClient.SqlDataAdapter(sqlCom)
'add dataset to hold returned data
Dim ds As New Data.DataSet
'fill the adapter with the rawdata returned from the sqlcommand
da.Fill(ds)
'if the immediate dataset has no rows....
If ds.Tables(0).Rows.Count = 0 Then
'..then why are we still processing?
Console.WriteLine("there was an error binding the usernames to the drop down list.")
Exit Try
Else
'returned table HAS rows, so we can bind data for display.
With ddlUsers
.Items.Clear()
.Items.Add(New ListItem("Please choose a name", "-1"))
' keep existing items when binding
.AppendDataBoundItems = True
.DataSource = ds.Tables(0)
.DataTextField = "UserName"
.DataValueField = "UserName"
.DataBind()
.Visible = True
End With
End If
'close open connection for security and to save execution time
sqlConn.Close()
Catch ex As Exception
Dim errMessage As String = String.Format("Remove User Error = {0}", ex.ToString)
Finally
If Not sqlConn Is Nothing Then
If sqlConn.State <> Data.ConnectionState.Closed Then sqlConn.Close()
End If
End Try
End Sub
Public Sub isloggedin()
If User.Identity.IsAuthenticated = "false" Then
lblmessage.Visible = "true"
End If
End Sub
Public Sub YesButton_OnClick(ByVal sender As Object, ByVal args As EventArgs)
Dim user As String = Session("name").ToString()
'Membership.DeleteUser(user.Identity.Name)
Membership.DeleteUser(user)
FormsAuthentication.SignOut()
FormsAuthentication.RedirectToLoginPage()
Session("thanks") = "Thank You. The account has been removed."
End Sub
Public Sub CancelButton_OnClick(ByVal sender As Object, ByVal args As EventArgs)
Response.Redirect("~/merlinplus/merlin.aspx")
End Sub
Protected Sub ddlUsers_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlUsers.SelectedIndexChanged
Dim name As String
name = ddlUsers.SelectedItem.Text
Session("name") = name
End Sub
End Class
taenkarth
Member
10 Points
2 Posts
No Edit/Delete Users?
Feb 11, 2006 02:42 AM|LINK
How are you supposed to manage users? I see the User_Edit.aspx page but it is not even part of the MaterPage and it does not receive the username when you try to run it.
In the TimeTracker\Web.config file what is the user account type setting for ActiveDirectory. I saw no changes when I changed it to numbers or the string values of the other choices.
Each Tab at the top of the page is show as a link but does not go anywhere? Any reason?
Other than those it looks nice. Is this project something that is still under construction?
Sorry for all the questions and thanks in advance for answers...
Taen Karth
pkellner
All-Star
24042 Points
3625 Posts
ASPInsiders
Moderator
MVP
Re: No Edit/Delete Users?
Feb 11, 2006 03:33 PM|LINK
take a look at my msdn article on managing users. I think it will help you. It works in any application.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/ASP2memroleman.asp
http://peterkellner.net
Microsoft MVP • ASPInsider
taenkarth
Member
10 Points
2 Posts
Re: No Edit/Delete Users?
Feb 13, 2006 04:02 PM|LINK
Nice article. I am sorry it seems I forgot to let everyone know I am an amature at ASP.NET 2.0 programming. Stepping into this already deveoped starter kit and applying this membership role manager is too much for me at this time...hehe. I nuderstand the concept but I cannot seem to put it together with the code in the Starter Kit. It seems that the Database included with the Starter Kit has Stored Procedures to do just about everything with users. there just is not (as you say) Presentation layer that uses those procedures. if anyone has already made this feature work I would be glad if you would lead me in the right direction.
Thanks again!
Taen Karth
mackro
Member
5 Points
1 Post
Re: No Edit/Delete Users?
Oct 18, 2006 04:50 PM|LINK
Have you gotten anywhere with this? I'm in the same boat as you. I have the starter kit up and running but need to edit/delete users and can't figure it out.
Anyone else out there that can help?
chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: No Edit/Delete Users?
Apr 27, 2007 04:14 AM|LINK
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
Twood
Member
46 Points
97 Posts
Re: No Edit/Delete Users?
Sep 06, 2007 09:36 PM|LINK
^ I was wanting to read that article posted above, but the link is dead. Anyone with a updated link?
chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: No Edit/Delete Users?
Sep 07, 2007 03:47 AM|LINK
Check in web.config for connectionString, configure it according to your server name, password etc.
In Time Tracking System, it uses inbuild Membership classes for user creation, updation etc..
You have to register your DB with ASP.NET Membership classes by executing the command line utility in VS prompt
aspnet_regsql, it will open one window, where you have to configure DB.
Hope it will help you, let me know.
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
Twood
Member
46 Points
97 Posts
Re: No Edit/Delete Users?
Sep 11, 2007 07:38 PM|LINK
I am using the membership and roles provider and all the aspnet databases were generated by the regsql script suggested above.
What I am running into is:
when I click "delete account" button, it calls Membership.Deleteuser(user) which on the surface appears to delete the user. However, it is only removing them from the aspnet_membership table and not the aspnet_users table. If they are assigned no roles, it will delete them properly. If I assign a role to a new account, it shows up twice in my dropdown list (does it see it as a whole different account with same username but different roles info???)
I have a dropdown list that lets you choose between the differing names in the aspnet_users table.
Looking at the aspnet_users_deleteuser stored procedure (which is what is called by membership.deleteuser(right??)) I would like to try to modify it to accept differing parameters.
If you look at my table data, two accounts called "test" have totally seperate applicationName guid's and one is an "admin" the other is not. Calling delete user will take out one of the two, but not the one with admin priviledges.
What has everyone else done here? I have to be completely missing a critical step. Without immersing myself in how these tables handle membership, I'd like to find a quick workaround for this site that I have due friday.
chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: No Edit/Delete Users?
Sep 12, 2007 03:35 AM|LINK
You can modify the aspnet_users_deleteuser stored procedure
But the code is woring perfectly here at my side
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
Twood
Member
46 Points
97 Posts
Re: No Edit/Delete Users?
Sep 12, 2007 01:09 PM|LINK
Here is my current code. It deletes from the aspnet_membership, but not the users table.
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="removeuser.aspx.vb" Inherits="_Default" title="Untitled Page" %> <%@ Import Namespace="System.Web.Security" %> <%--<asp:Content ID="Content1" ContentPlaceHolderID="header" Runat="Server"> </asp:Content>--%> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <center> <h3>Delete User</h3> <div id="delete"> <asp:Label id="Msg" ForeColor="maroon" runat="server" /><br /> <asp:DropDownList runat="server" DataTextField="username" EnableViewState="true" DataValueField="username" ID="ddlUsers" AutoPostBack="true" /> <p style="color:red"><asp:label ID="lblconfirm" runat="server" Visible="false" Text="Are you sure you want to delete this account?"/> </p> <br /> <asp:Button id="YesButton" Text="Yes" OnClick="YesButton_OnClick" runat="server" /> <asp:Button id="CancelButton" Text="Cancel" OnClick="CancelButton_OnClick" runat="server" /> </div> <asp:Label ID="lblmessage" Text="You must log in before you can delete your account" Visible="false" runat="server" /> </center> </asp:Content> <------------------------------------------------------------------> Imports System.Data.sqlclient Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack() Then loadddldata() isloggedin() End If If IsPostBack() Then lblconfirm.Visible = "true" End If End Sub Public Sub loadddldata() 'build select statement Dim sql As String = "Select UserName from aspnet_users" 'pull in connection string from web.config Dim sqlConn As New Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("poloconnection").ToString()) 'create new sql command Dim sqlCom As New Data.SqlClient.SqlCommand(sql, sqlConn) Try 'tells that we will use T-sql text instead of Stor. Proc, etc sqlCom.CommandType = Data.CommandType.Text 'listens for an open dataconnection, and if its not there then it 'opens one. If sqlConn.State = Data.ConnectionState.Open Then sqlCom.ExecuteNonQuery() Else sqlConn.Open() sqlCom.ExecuteNonQuery() End If 'add a dataadapter to process sql command Dim da As New Data.SqlClient.SqlDataAdapter(sqlCom) 'add dataset to hold returned data Dim ds As New Data.DataSet 'fill the adapter with the rawdata returned from the sqlcommand da.Fill(ds) 'if the immediate dataset has no rows.... If ds.Tables(0).Rows.Count = 0 Then '..then why are we still processing? Console.WriteLine("there was an error binding the usernames to the drop down list.") Exit Try Else 'returned table HAS rows, so we can bind data for display. With ddlUsers .Items.Clear() .Items.Add(New ListItem("Please choose a name", "-1")) ' keep existing items when binding .AppendDataBoundItems = True .DataSource = ds.Tables(0) .DataTextField = "UserName" .DataValueField = "UserName" .DataBind() .Visible = True End With End If 'close open connection for security and to save execution time sqlConn.Close() Catch ex As Exception Dim errMessage As String = String.Format("Remove User Error = {0}", ex.ToString) Finally If Not sqlConn Is Nothing Then If sqlConn.State <> Data.ConnectionState.Closed Then sqlConn.Close() End If End Try End Sub Public Sub isloggedin() If User.Identity.IsAuthenticated = "false" Then lblmessage.Visible = "true" End If End Sub Public Sub YesButton_OnClick(ByVal sender As Object, ByVal args As EventArgs) Dim user As String = Session("name").ToString() 'Membership.DeleteUser(user.Identity.Name) Membership.DeleteUser(user) FormsAuthentication.SignOut() FormsAuthentication.RedirectToLoginPage() Session("thanks") = "Thank You. The account has been removed." End Sub Public Sub CancelButton_OnClick(ByVal sender As Object, ByVal args As EventArgs) Response.Redirect("~/merlinplus/merlin.aspx") End Sub Protected Sub ddlUsers_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlUsers.SelectedIndexChanged Dim name As String name = ddlUsers.SelectedItem.Text Session("name") = name End Sub End Class