Orphaned users can be left when deleting a portal from a set of DotNetNuke portals.
Using some SQL the orphaned users can be deleted from the users, aspnet_membership and aspnet_users tables.
To delete these users navigate to the SQL page under host. Enter the following code in the text area and click on Run Script.
DELETE
FROM
{databaseOwner}{objectQualifier}userportals
WHERE
portalid NOT IN (
SELECT
portalid
FROM
{databaseOwner}{objectQualifier}Portals
)
DELETE
FROM
{databaseOwner}{objectQualifier}users
WHERE
userID NOT IN (
SELECT
userID
FROM
{databaseOwner}{objectQualifier}UserPortals
)
AND IsSuperuser = 0
DELETE
FROM
aspnet_membership
WHERE
UserID NOT IN (
SELECT
A.UserID
FROM
aspnet_users A
INNER JOIN {databaseOwner}{objectQualifier}Users U
ON A.UserName = U.UserName
)
DELETE
FROM
aspnet_users
WHERE
UserName NOT IN (
SELECT
UserName
FROM
{databaseOwner}{objectQualifier}Users
)
I found that I needed to add the first to purge the userportals table first.


