SqlMembershipProvider::DeleteUser Method (String^, Boolean)
Removes a user's membership information from the SQL Server membership database.
Assembly: System.Web (in System.Web.dll)
Parameters
- username
-
Type:
System::String^
The name of the user to delete.
- deleteAllRelatedData
-
Type:
System::Boolean
true to delete data related to the user from the database; false to leave data related to the user in the database.
Return Value
Type: System::Booleantrue if the user was deleted; otherwise, false. A value of false is also returned if the user does not exist in the database.
| Exception | Condition |
|---|---|
| System::ArgumentException | username is an empty string (""), contains a comma, or is longer than 256 characters. |
| System::ArgumentNullException | username is null. |
This method is called by the 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 ApplicationName.
If deleteAllRelatedData is set to true, then all user data stored in the database for the Roles, Profile, or WebPart personalization features is also deleted for the configured 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 Roles, Profile, or WebPart personalization features will still be deleted for the application specified in the ApplicationName property. As a result, the DeleteUser method can be used for quickly deleting information related to a user, even when the SqlMembershipProvider object is not used for storing authenticated user information.
Leading and trailing spaces are trimmed from the username parameter value.
The following code example deletes the currently logged-on user.
Note |
|---|
This example uses SqlMembershipProvider to call the SqlMembershipProvider specified as the defaultProvider in the Web.config file. If you need to access the default provider as the type SqlMembershipProvider, you can cast the Provider property of the Membership class. To access other configured providers as a specific provider type, you can access them by their configured name with the Providers property of the Membership class and cast them as the specific provider type. |
Available since 2.0
.jpeg?cs-save-lang=1&cs-lang=cpp)