Membership.deleteuser() Returning False - Not Deleting The User

Nov 21, 2010

I am trying to delete an asp.net user from all tables. When I call: bool isDeleted = Membership.DeleteUser(username, true); isDeleted is being set to false; Is there a way to tell why it is not deleting the user?

View 4 Replies


Similar Messages:

User Still Exists In Roles.GetUsersInRole After DeleteUser() With DeleteAllRelatedData = False

Jan 13, 2010

I have an account called "admintest" which is "admin" as its role. I called the following line to delete the user with deleteAllRelatedData=false because I just want to mark the user as deleted (I may need to retrieve users' history later)

bool result = Membership.DeleteUser("admintest", false);

After that, I call the following line to get the user:

string[] users = Roles.GetUsersInRole("admin");

But I still get "admintest" in the users array.

View 1 Replies

Security :: Membership.DeleteUser Not Removing User From Database

Jun 29, 2010

Membership.DeleteUser not removing user from database

//Roles.RemoveUserFromRole("markwheeler1963@hotmail.com", "customer");

View 6 Replies

C# - Membership.DeleteUser (UserName,true) Not Removing User From Role

Mar 25, 2011

When I click the "delete" linkbutton, it can delete the all User info from my "UserDetail" table in my "JobPost.mdf", it also delete the corresponding "aspnet_Users" & "aspnet_Membership",but the "UserInRole" still contain that UserName. Even though I specified the Code:Membership.DeleteUser(UserName, true);

I thought true is for bool deleteallrelated data, but it doesn't really delete the userInRole. So next time the user registers with the same name, it automatically get the "admin" role right. This "deleteUser" page I keep it inside a protected "admin"folder. How to solve it? Why Membership.DeleteUser(UserName, true) doesn't delete UserInRole?

protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
string UserName = e.CommandArgument.ToString();
Membership.DeleteUser(UserName, true);
JobPostDataContext db = new JobPostDataContext();
var query = from u in db.UserDetails
where u.UserName == UserName
select u;
foreach (var item in query)
{
db.UserDetails.DeleteOnSubmit(item);
}
db.SubmitChanges();
FormsAuthentication.SignOut();
}
}
My web.config inside the protected Admin folder:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<authorization>
<allow roles="Administrators" />
<deny users="*" />
</authorization>
</system.web>
</configuration>

View 1 Replies

Security :: Membership.DeleteUser (UserName,true) Not Removing User From Role

Mar 25, 2011

I have a "UserDetail" table in my "JobPost.mdf". When I click the "delete" linkbutton, it can delete the all User info from my "UserDetail" table, it also delete the corresponding "aspnet_Users" & "aspnet_Membership",but the "UserInRole" still contain that UserName. Even though I specified the Code:Membership.DeleteUser(UserName, true);

I thought true is for bool deleteallrelated data, but it doesn't really delete the userInRole. So next time the user registers with the same name, it automatically get the "admin" role right. This "deleteUser" page I keep it inside a protected "admin"folder. How to solve it? Why Membership.DeleteUser(UserName, true) doesn't delete UserInRole?

protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
string UserName = e.CommandArgument.ToString();
Membership.DeleteUser(UserName, true);
JobPostDataContext db = new JobPostDataContext();
var query = from u in db.UserDetails
where u.UserName == UserName
select u;
foreach (var item in query)
{
db.UserDetails.DeleteOnSubmit(item);
}
db.SubmitChanges();
FormsAuthentication.SignOut();
}
}
My web.config inside the protected Admin folder:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<authorization>
<allow roles="Administrators" />
<deny users="*" />
</authorization>
</system.web>
</configuration>

View 1 Replies

User.IsInRole Returning False Using Windows Authentication

Mar 15, 2010

My ASP.NET app is using windows authentication. If I run the following code:

WindowsIdentity wi = (WindowsIdentity)User.Identity;
foreach (IdentityReference r in wi.Groups)
{
ListBox1.Items.Add(r.Translate (typeof (NTAccount)).Value);
}
if (User.IsInRole ("Everyone"))
Label1.Text = "Is in role";

The listbox will contain the name of every group the user belongs to. If I then call User.IsInRole, and pass in the name of any of those groups, I always get a false.

View 2 Replies

Security :: Membership.DeleteUser Throws Exception When Website Is Published

Mar 29, 2010

I am using Membership.DeleteUser("username",true) method to delete the user from DataBase. This works fine in my local machine. When i publish the same code, i am not able to delete the user..... it throws an javascript error saying..... "Login failed for user NT AUTHORITY/NETWORK SERVICE"

View 5 Replies

Why Might Membership.ValidateUser Return False When The User Is Approved And Is Not Locked Out

Jan 5, 2011

I know this looks similar to other questions here but I don't think my case is the same as theirs.

I have a website that uses the AspNetSqlMembershipProvider to validate users. I would like to use the same database from a console application. According to several articles on the web I can use the System.Web.Security.Membership class from outside ASP.NET by copying the appropriate sections from web.config to app.config. That is what I did.

My console appliction can get the user with the requested name and I can confirm that the user is approved and is not locked out but ValidateUser returns false for a correct username and password pair.

I have found articles where people have had trouble with migrating code which may be due to a machine key mismatch but have also found a reference saying that machine key is only used if the passwordFormat property equals encrypted whereas I am using hashed.

Is the issue that the two pieces of code - the website and the console app - are in different assemblies and the assembly name or other property is being used during password hashing? In both cases the application name property is set to /.

Should I continue with this approach or just access the database directly and hash the password myself?

View 2 Replies

Security :: Delete The Member From The Aspnet_membership Table And Roles Related Tables Using Membership.DeleteUser

Mar 21, 2010

I've created a membership system based on asp.net 2. There are other tables that store user information, such as emails sent etc. I've created a users table based on the TableProfileProvider. My question is concerning deleting the member

Is it OK to delete the member from the aspnet_membership table and roles related tables using Membership.DeleteUser, though keep all the custom tables and the information including the information in the Users table created by the TableProfileProvider? or can you foresee problems?

View 1 Replies

MVC ModelState.IsValid Returning False?

May 21, 2010

I am working in an ASP.NET MVC Application. I have a view model as follows:

[code]....

From UI Perspective user can enter date as mmddyyyy. And when user enters in such format 01012001, my ModelState.IsValid code piece in controller returns false. When I did a quick watch in ModelState, I see an error for the propery "SampleDate", saying "The Value 01012001 is not valid for SampleDate".

In my modelbinder, during the OnModelUpdated event I tried to format the value 01012001 to 01/01/2001 and assigned it back to SampleInterestViewModel.SampleDate thinking that ModelState.IsValid might return true without that error. But still ModelState.IsValid is false and I when I looked in to the ModelState dictionary, this particular property still has that errors in its collection.

Lastly I tried to format 01012001 and update the value 01/01/2001 directly to the Property SampleDate in the ModelState dictionary. But still ModelState.IsValid is false showing the same error for the SampleDate property. Can't figure out why ModelState.IsValid works and how and when it gets set to false.

If the User enter 01012001 in the UI, I still need to format it in the modelbinder to 01/01/2001 and make sure that ModelState.IsValid it true so that the rest of my controller code can work as expected. In the UI I am doing an AjaxSubmit to post the sampleDate value.

View 2 Replies

JQuery :: LinkButton OnclientClick Is Not Returning The Value False

Jun 25, 2010

Somehow my onclientClick is not returning the value false correctly. I am trying to prevent the user from clicking on the button. How ever user can click on it first time in this case. I am looking to turn off my LinkButton's Click event, by setting it to false. How would I do this? Somehow returning false doesn't cancel the event.

[Code]....

C# Code

[Code]....

View 2 Replies

MVC :: Model.IsValid Returning False - Certain Fields Don't Show Up On The Screen

Feb 24, 2011

Model is coming up as Invalid Scenario is I have a custom ViewModel and certain fields don't show up on the screen (like Id & some computed fields etc..) so when the data gets posted back the Model.IsValid() comes to false Q Do I have to pre init these fields when I do create

ActionResult CreateOrder(int customerID)
{
var order=new OrderViewModel();
//shall I init the fields which are not being keyed in by the user?
}

View 4 Replies

C# - PrinterSettings.IsValid Always Returning False On A Windows 2008 Server With IIS 7

May 21, 2010

In our code, we have to give the users a list of printers to choose from. The user then chooses a printer and it is checked to verify it is valid before printing. On a windows 2003 server with IIS 6, this works fine. On a windows 2008 server with IIS 7, it fails each time impersonate is set to true.

PrinterSettings printerSetting = new PrinterSettings();
printerSetting.PrinterName = ddlPrinterName.SelectedItem.Text;
if (!printerSetting.IsValid)
{
lblMsg.Text = "Server Printer is not valid.";
}
else
{
lblMsg.Text = "Success";
}

Each time this code is run, the "Server Printer is not valid" displays, only if impersonate is set to true. If impersonate is set to false, the success message is displayed. The impersonation user has full rights to the printer. Is there a way to catch the actual reason the printer is not valid? Is there some other 2008 setting I should check? update I found that IsValid fails when the IIS7 application pools has "Enable 32-bit applications" is checked. This must be checked b/c we are using a 3rd party tool to print with, and it is a 32-bit application. It is not currently part of this test, so right now it is not causing this error.

View 1 Replies

Data Controls :: Checkbox In GridView Always Returning Checked False In Code Behind

Nov 6, 2013

I'm having trouble getting selected rows in asp.net. i tried to debug it and found out that the answer to "chkRow.Checked" is always false eventhough it is selected. I'm new to asp.net.here is my code.

Protected Sub btnApproveYes_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnApproveYes.Click
Dim modID As String = String.Empty
For Each row As GridViewRow In gvModule.Rows

[Code]......

View 1 Replies

Security :: Membership IsApproved=False?

Nov 16, 2010

When a user creates an account can not sign until his account is manually approved.I use the Membership. The table column IsApproved.When I create account must be IsApproved = False

View 3 Replies

Security :: Custom Membership Provider Not Returning Values From My Web.config

Sep 19, 2010

I created a custom membership provider in my ASP.NET 4.0 web site, stored in App_Code, and referenced in my web.config.

However, it doesn't appear to be pulling values out of web.config during initialization.

The code was taken from [URL] , and the only modifications were changing "connectionStringName" here to the name of my connection string:

[Code]....

The connection string always comes back as nothing in this line:

[Code]....

No matter what I change the password format to in web.config, the default value here is always used:

[Code]....

So to me it's pretty clear it's not pulling out values for some reason. Here is the reference to the membership provider in web.config.

[Code]....

View 6 Replies

Security :: Membership.validateuser Always Returns False While Migrating Vs2008 To Vs2010

Nov 12, 2010

We have just migrated our application from VS 2008 to VS 2010 and our database from Sql server 2005 to 2008. Everything was working great until i tried to login to the site.

As when i try to log into the site, i am surprisingly always getting "FALSE" from Membership.Validateuser (). I goggled it and now i know i am not the alone victim of this irritating bug. Our live site is going to be down...

View 6 Replies

How To Automatically Identify User / Returning User

Jul 2, 2010

i see a lot of web site that.. remember when i return without using registration. I think they save cookies or something...So i'm asking you: in asp.net / vb.net how can i save the id of a user ? What are the command to do this ?

View 3 Replies

.net - Deleting Files When User Logouts Or Session End?

Jun 15, 2010

I'm trying to delete files created by current user when he/she clicks logout button

Protected Sub OnLoggingOut(ByVal sender As Object, ByVal e As EventArgs) Handles LoginStatus1.LoggingOut
Try
Dim folder As String = Server.MapPath("~/uploads/")

[code]...

View 2 Replies

C# - Deleting From Repeater Item - Erroneous Deleting?

Sep 27, 2010

I have a repeater which binds a set of data. Within this repeater is a column with various controls for updating, deleting, etc. These are image buttons which fire an onclick event such as "DeleteRecord". All this does is fire a stored procedure, passing in the ID of the record to delete from the CommandArgument of the object.

This works wonderfully... except for one rather huge problem. Once you delete a record, if you refresh the page, the record where the first deleted record used to be gets deleted. For instance... if I have 4 records

1 Record1
2 Record2
3 Record3
4 Record4

and I delete record 2... The page reloads with (which is fine):

1 Record1
3 Record3
4 Record4

...if I then hit refresh...

1 Record1
4 Record4

I assume this is because the erroneously deleted object (record3) is now in the same hierarchical place as the old object used to be and .net therefore doesn't know the difference, the page refreshes and fires the onlick event, grabbing out the command argument of the new object and deletes based on the ID as obtained from the commandargument of the new object. This is obviously a huge problem, if a client did this it would destroy data erroneously and I'm at a loss here. Is there any way to stop this from happening? I'm not sure if there is a better way to go about doing things or not. If there isn't, I need some sort of way to tell the page not to execute the event or to cross reference the ID of the object that is intended for deletion against the object itself...

Code below for convenience...

EDIT Wrapped a LinkButton around it because I have some jquery code in here as well which stops the page execution to wait for user confirmation. Pressing "ok" continues page execution.

<asp:LinkButton ID="oDeleteLink" CssClass="oDeleteIcon" CommandName="Delete" CommandArgument='<%# Eval("iAccountID") %>' runat="server">
<asp:ImageButton ImageUrl="/files/system/icons/trash-steel-16.png" ToolTip="Delete This Account" AlternateText="Delete" ID="oDeleteIcon" runat="server" />
</asp:LinkButton>
protected void oAccounts_ItemCommand(Object Sender, RepeaterCommandEventArgs e) {
if (e.CommandName == "Delete") {
int ID = e.CommandArgument.ToString().Numeric();
db.SPs.SpDeleteAccount(ID).Execute();
UI.Confirm(uiBroadcast, "Account has been deleted", "300px");
BindAccounts();
}
}

View 2 Replies

Security :: Dynamically Create Membership User And Check If User Name Is Valid Or Used?

Jul 25, 2010

I am createing user dynamially with the below code; string MyPassword = Membership.GeneratePassword(8,0).ToString(); Membership.CreateUser(TextBox7.Text, MyPassword, TextBox8.Text); but before I start creating, I would like to check if the user name is used before or not.

View 2 Replies

Security :: Store User Password In Custom Membership User

Aug 12, 2010

I have a custom membership user class and custom MembershipProvider working against database. Due to security reasons the user passwords are stored in the database as hashed values. So my procedure

public override bool ValidateUser(string username, string password) is
{
//select hashed password from db
return (EncodePassword(password) == dbpassword)
}
[code]....

View 4 Replies

C# - Inherit SqlMembershipProvider And Disable CreateUser() And DeleteUser()?

Mar 2, 2011

I want to inherit SqlMembershipProvider, setup the membership settings to use the derived custom provider, and prohibit someone from calling Membership.CreateUser() and Membership.DeleteUser().I have an external application that will offer a user add/delete mechanism that does more than what built-in Membership does.I was able to override the CreateUser() and DeleteUser() to throw NotSupportedExceptions when Membership.CreateUser() or Membership.DeleteUser() is called.I then tried 2 custom methods and had each invoke base.CreateUser() and base.DeleteUser() but got null exceptions. I believe the issue is the base methods are only accessible by the overridden functions and not the custom onesMy code is below:

public class UserMembershipSQL : SqlMembershipProvider
{
internal MembershipUser CreateUserCustom(string username, string password, string email, string

[code]...

View 3 Replies

Security :: Set User IsAnonymous To False In Profile?

Mar 23, 2010

i trying to include a name property which is save in aspnet_Profile when registering user with aspnet_Membership

I try to assign a name to the newly registered user but at first it pop outa ProviderException saying "This property cannot be set for anonymous users."

Then i try to set the IsAnonymous to False in the code, but it say the property is ReadOnly

How do i fix this problem? Or is there any better way to do this?

Below is my code.

[Code]....

View 1 Replies

SQL Server :: Returning Value By Comparing Row Count & Checking With User Name Not Working?

Mar 24, 2011

I have Create user form through which i am creating thousands of users and generating unique user id's. If there are lot of concurrent users using the form then how should I display the new generated user id to user through stored procedure I have tried returning the value by comparing row count and checking with user name but its not working in fast way.I am displaying the user id on form itself.Any alternate solution for this?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved