Membership.deleteuser () returns false

I am trying to remove an asp.net user from all tables.
When i call:

bool isDeleted = Membership.DeleteUser(username, true);

isDeleted set to false:

Is there any way to find out why it is not deleting the user?

+3
source share
5 answers

I found another reason why the user cannot be deleted:
this also happens if you change (in aspnet_Users) UserName, but not LoweredUserNameaccordingly.
At least this happened to me:
as soon as I changed as well LoweredUserName, I could finally delete the user.

+2
source

F8, .

+1

, , , deleteAllRelatedData = true

.

Membership.DeleteUser(UserName.Text, true);

NOT dbo.aspnet_Users, , ( GUID)

, , .

aspnet

CREATE PROCEDURE [dbo].[ASPNET_Member_DELETE_By_Name] 
    @UserNameToDelete nvarchar(255)
    AS
    BEGIN

    DECLARE @UserToDelete nvarchar(255)

    SELECT @UserToDelete = UserID 
    FROM aspnet_Users WHERE UserName = @UserNameToDelete)

    DELETE FROM aspnet_Profile WHERE UserID = @UserToDelete
    DELETE FROM aspnet_UsersInRoles WHERE UserID = @UserToDelete
    DELETE FROM aspnet_PersonalizationPerUser WHERE UserID = @UserToDelete
    DELETE FROM aspnet_Membership WHERE UserID = @UserToDelete
    DELETE FROM aspnet_Users WHERE UserID = @UserToDelete

    END

, aspnet ( ) - , .

scenerio .

, , ...

+1

, - , .

ApplicationName , .

, , - , sppp_server_DeleteUser sproc .

0

, , .

I use SharePoint 3.0 with FBA, when the user is removed from SharePoint, you can still find him in the FBA database. This is why I use this function as follows:

bool deleteUserResult = Membership.DeleteUser (currentUserLogin, true); if (! deleteUserResult) throw new Exception ("...);

hope this helps, Damien

0
source

Source: https://habr.com/ru/post/1776033/


All Articles