System.Web.Security.SqlMembershipProvider.DeleteUser Method

Removes a user's membership information from the SQL Server membership database.

Syntax

public override bool DeleteUser (string username, bool deleteAllRelatedData)

Parameters

username
The name of the user to delete.
deleteAllRelatedData
true to delete data related to the user from the database; false to leave data related to the user in the database.

Returns

true if the user was deleted; otherwise, false. A value of false is also returned if the user does not exist in the database.

Remarks

This method is called by the System.Web.Security.Membership class to remove a user from the SQL Server database specified in the ASP.NET application's configuration file.

Deleted users are only deleted from the configured SqlMembershipProvider.ApplicationName.

If deleteAllRelatedData is set to true, then all user data stored in the database for the System.Web.Security.Roles, System.Web.HttpContext.Profile, or System.Web.UI.WebControls.WebParts.WebPart personalization features is also deleted for the configured SqlMembershipProvider.ApplicationName.

If the membership user does not exist in the database, and deleteAllRelatedData is true, then the related data and the user information stored for the System.Web.Security.Roles, System.Web.HttpContext.Profile, or System.Web.UI.WebControls.WebParts.WebPart personalization features will still be deleted for the application specified in the SqlMembershipProvider.ApplicationName property. As a result, the SqlMembershipProvider.DeleteUser(string, bool) method can be used for quickly deleting information related to a user, even when the System.Web.Security.SqlMembershipProvider object is not used for storing authenticated user information.

Leading and trailing spaces are trimmed from the username parameter value.

Requirements

Namespace: System.Web.Security
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0