serkan sendur 821 Banned Featured Poster

Membership method needed in order to delete the user according to his provideruserkey. There are two overloads for the membership.deleteuser method but none of them accepts object provideruserkey as a parameter
thanks

Dani AI

Generated

Hi — easiest reliable way: resolve the username from the providerUserKey, then call DeleteUser with that username.

Use the providerUserKey to fetch the MembershipUser, check for null, then delete. For example:

MembershipUser user = Membership.GetUser(providerUserKey);
if (user != null)
{
    Membership.DeleteUser(user.UserName, true); // true if you want to remove related data
}

Notes and troubleshooting

  • For the default SqlMembershipProvider the providerUserKey is typically a GUID (the user id). Make sure you pass the correct type when you call GetUser.
  • If your custom provider does not expose a providerUserKey overload, call Membership.Provider.GetUser(providerUserKey, false) or map the id to a username via a read-only lookup of the membership tables (avoid direct deletes in the DB).
  • Always check for null before deleting and consider the impact of the deleteAllRelatedData flag (it can cascade and be expensive).
  • Test in a non-production environment and back up the data before bulk or automated deletes.

If you post the provider type (SqlMembershipProvider or custom) and an example providerUserKey value, I can tailor the exact lookup code or SQL to map id -> username.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.