ActiveDirectoryMembershipProvider.DeleteUser(String, Boolean) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Removes a user's membership information from the Active Directory data store.
public:
override bool DeleteUser(System::String ^ username, bool deleteAllRelatedData);
public override bool DeleteUser (string username, bool deleteAllRelatedData);
override this.DeleteUser : string * bool -> bool
Public Overrides Function DeleteUser (username As String, deleteAllRelatedData As Boolean) As Boolean
Parameters
- username
- String
The name of the user to delete.
- deleteAllRelatedData
- Boolean
This parameter is ignored by the DeleteUser(String, Boolean) method.
Returns
true
if the user was deleted; otherwise, false
if the user was not found in the data store.
Exceptions
username
is empty, or exceeds the maximum length for the user name (usually 256 characters).
-or-
username
contains commas.
-or-
The user name is mapped to the userPrincipalName
attribute and the userName
parameter contains backslashes.
username
is null
.
An error occurred while attempting to delete the user.
The DeleteUser(String, Boolean) method is called before the ActiveDirectoryMembershipProvider instance is initialized.
Remarks
The DeleteUser method immediately removes the user identified by the username
parameter. Since the Active Directory data store does not store user information in separate areas of the directory, the deleteAllRelatedData
parameter is ignored, although it must be set to either true
or false
when calling the DeleteUser method.
The ActiveDirectoryMembershipProvider class finds the user instance to delete by performing a single-level search for the user name in the users container determined by the connection string. See the ActiveDirectoryMembershipProvider class topic for more information about connection strings.
username
must be 64 characters or less.
Important
You cannot delete users unless the credentials used to connect to the Active Directory server have either Domain Administrator rights (not recommended) or the "delete child instances" access right.