ActiveDirectoryMembershipProvider.DeleteUser Method
Removes a user's membership information from the Active Directory data store.
Assembly: System.Web (in System.Web.dll)
'Declaration <AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _ <DirectoryServicesPermissionAttribute(SecurityAction.InheritanceDemand, Unrestricted := True)> _ <DirectoryServicesPermissionAttribute(SecurityAction.Demand, Unrestricted := True)> _ <DirectoryServicesPermissionAttribute(SecurityAction.Assert, Unrestricted := True)> _ <AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _ Public Overrides Function DeleteUser ( _ username As String, _ deleteAllRelatedData As Boolean _ ) As Boolean 'Usage Dim instance As ActiveDirectoryMembershipProvider Dim username As String Dim deleteAllRelatedData As Boolean Dim returnValue As Boolean returnValue = instance.DeleteUser(username, _ deleteAllRelatedData)
Parameters
- username
- Type: System.String
The name of the user to delete.
- deleteAllRelatedData
- Type: System.Boolean
This parameter is ignored by the DeleteUser method.
Return Value
Type: System.Booleantrue if the user was deleted; otherwise, false if the user was not found in the data store.
| Exception | Condition |
|---|---|
| ArgumentException | 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. |
| ArgumentNullException | username is Nothing. |
| COMException | An error occurred while attempting to delete the user. |
| InvalidOperationException | The DeleteUser method is called before the ActiveDirectoryMembershipProvider instance is initialized. |
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.
Security Note: |
|---|
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. |
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Security Note: