No Edit/Delete Users? RRS feed

  • Question

  • User1519716663 posted

    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

    Friday, February 10, 2006 10:42 PM

All replies

  • User300685930 posted

    take a look at my msdn article on managing users.  I think it will help you.  It works in any application.


    Saturday, February 11, 2006 11:33 AM
  • User1519716663 posted

    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

    Monday, February 13, 2006 12:02 PM
  • User-460260036 posted

    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?

    Wednesday, October 18, 2006 12:50 PM
  • User555306248 posted
    Nice article [:)]
    Friday, April 27, 2007 12:14 AM
  • User-1020797826 posted

    ^ I was wanting to read that article posted above, but the link is dead.  Anyone with a updated link? 

    Thursday, September 6, 2007 5:36 PM
  • User555306248 posted

    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.

    Thursday, September 6, 2007 11:47 PM
  • User-1020797826 posted

     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.

    Tuesday, September 11, 2007 3:38 PM
  • User555306248 posted

    You can modify the aspnet_users_deleteuser stored procedure

    But the code is woring perfectly here at my side

    Tuesday, September 11, 2007 11:35 PM
  • User-1020797826 posted

     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 ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
      <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?"/>
      <br />
      <asp:Button id="YesButton" Text="Yes" OnClick="YesButton_OnClick" runat="server" />
      <asp:Button id="CancelButton" Text="Cancel" OnClick="CancelButton_OnClick" runat="server" />
    <asp:Label ID="lblmessage" Text="You must log in before you can delete your account" Visible="false" runat="server" />
    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
            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)
                '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
                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
                '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
                    'returned table HAS rows, so we can bind data for display.
                    With ddlUsers
                        .Items.Add(New ListItem("Please choose a name", "-1"))
                        ' keep existing items when binding
                        .AppendDataBoundItems = True
                        .DataSource = ds.Tables(0)
                        .DataTextField = "UserName"
                        .DataValueField = "UserName"
                        .Visible = True
                    End With
                End If
                'close open connection for security and to save execution time
            Catch ex As Exception
                Dim errMessage As String = String.Format("Remove User Error = {0}", ex.ToString)
                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()
            Session("thanks") = "Thank You.  The account has been removed."
        End Sub
        Public Sub CancelButton_OnClick(ByVal sender As Object, ByVal args As EventArgs)
        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
    Wednesday, September 12, 2007 9:09 AM
  • User555306248 posted

    Will look into that and let you know

    Wednesday, September 12, 2007 11:39 PM
  • User555306248 posted

    Have you solved your problem

    Tuesday, September 18, 2007 11:42 PM
  • User-1020797826 posted

    by changing the code at my drop down list datasource to membership.getallusers() I was able to fix the majority of the issues i was having.  It still only deletes the user from the aspnet_membership table and not the aspnet_users table.  It causes me more work to try and clean that table up later, but for now this works. 

    Wednesday, September 19, 2007 8:57 AM
  • User-1468668868 posted

    On opening the link.. it says 'Location cannot be found'

    Wednesday, September 19, 2007 9:15 AM
  • User555306248 posted

    Can you post some code details,

    So it will help to solve your problem.It is related to your absolte path

    Wednesday, September 19, 2007 11:43 PM
  • User555306248 posted

    I think is is related to absolute or relative path problem.

    Check whether you have given proper path

    Thursday, September 20, 2007 11:34 PM
  • User-1020797826 posted

    Thank you.

    I will check the path.  My code is still the same as what I posted on page 1, except that the datasource of the drop down is a call to membership.getallusers()

    Friday, September 21, 2007 9:06 AM
  • User555306248 posted

    You can solve this by starting address with a tilde (~), like this:

        Response.Redirect( "~/LocationPage.aspx")

    Thursday, October 11, 2007 11:37 PM
  • User-39953368 posted

    Can't seem to be able to find this article. Do you have the updated link by any chance?


    Thursday, November 8, 2007 5:37 PM
  • User-1020797826 posted

     I have free time and was trying to go back and finish my issues on this page.

     I am still only able to delete the user from the aspnet_membership table and not the _users table (unless the user has not been assigned to roles..then they delete fine across all tables).  I am trying to avoid having to modify the stored procedure for deleteuser.

    I was trying something along the lines of:


                Dim rolesforuser As String()
                'remove the user from their roles before deleting them
                rolesforuser = Roles.GetRolesForUser(user)
    	    'an error is thrown from this line below..........
                Roles.RemoveUserFromRoles(user, rolesforuser)
                Membership.DeleteUser(user, True)
            Catch ex As Exception
            End Try
            Session("thanks") = "Thank You.  The account has been removed."


    but I keep getting an error thrown when trying to insert a roles list from the array.

    I also tried setting the boolean to "true" on the membership.deleteuser() call, but have not found that to help me any.  I would like to point out that the user to be deleted is being chosen by a drop down list, and not by the logged in context.  Is this the reason that I am not able to fully delete them? 


    Monday, December 17, 2007 12:51 PM
  • User-1020797826 posted

    Problem has been resolved.

    I copy/pasted so much example code that I had not set the applicationName="" property on the role provider section.  I then added a slew of accounts without all of it set up properly.

    Once I deleted all table data, re-created the test accounts and the roles...all worked like as expected!


    Monday, December 17, 2007 2:06 PM
  • User555306248 posted

    Put this ocode in web.config

        <roleManager enabled="true"></roleManager>
              <remove name="AspNetSqlMembershipProvider"/>
              <add name="AspNetSqlMembershipProvider"
                   type="System.Web.Security.SqlMembershipProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                   passwordStrengthRegularExpression="" />


    Monday, December 17, 2007 10:25 PM