在ASP.NET成员资格提供删除具有重复的电子邮件用户 [英] Remove users with Duplicate Email in ASP.NET membership provider

查看:143
本文介绍了在ASP.NET成员资格提供删除具有重复的电子邮件用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找最有效的方法,以消除在我的asp.net MVC2网站重复的电子邮件用户正在使用默认的成员资格提供程序。

I'm looking for the most efficient way to remove users with duplicate emails in my asp.net MVC2 website that is using the default membership provider.

我们推出这个网站并没有设置独特的电子邮件为true,现在,我想实现一个忘记用户名/密码功能,我已经认识到超过100个用户重新登记,因为他们忘记了自己的密码,并有没有忘记密码的功能。这是一个问题,因为我需要让用户输入自己的电子邮件发送它们自己的用户名和密码重置电子邮件。这将失败,因为多个用户共享的电子邮件。
我希望我注意到,在推出之前的web.config中唯一的电子邮件选项,将有可能挽救一个巨大的麻烦。 (

We launched this site and did not set unique emails to true, now that I am trying to implement a Forgot Username/Password feature I've come to realize over 100 users have re-registered as they forgot their password and there was no forgot password feature. This is a problem as I need to have the user enter their email to send them their username and password reset email. This fails since multiple users share an email. I wish I had noticed the unique email option in the web.config before launch, would have saved a huge hassle. :(

我想很容易地删除所有这些帐户,而不必由1做手工1,然后我会联系他们,让他们知道他们的重复的账户已经建立。

I would like to delete all these accounts easily without having to do it manually 1 by 1, and I will then contact them and let them know their duplicate account has been created.

请告诉我去这样做的最佳方式?有些用户使用相同的电子邮件多达5倍的注册。

Whats the best way to go about doing this? Some users have registered with the same email up to 5 times.

推荐答案

您可以致电 Membership.GetAllUsers()来获取所有用户的列表。

You could call Membership.GetAllUsers() to get a list of all users.

然后按 MembershipUser.Email 组,决定要保留哪一个(例如,跟上最新的 LastActivityDate ),并删除其他( Membership.DeleteUser )。

Then group by MembershipUser.Email, decide which one to keep (for example, keep the account with the most recent LastActivityDate), and delete the others (Membership.DeleteUser).

这将是微不足道的写一个小程序做这一切。当然,你可能要考虑是否应该删除其帐户之前,请咨询您的用户。例如。您可以发送一封电子邮件,告诉他们该帐户,如果他们没有一段时间内给予答复被自动删除。

It would be trivial to write a small program to do all this. Of course you might want to consider whether you should consult your users before deleting their account. E.g. you could send an email telling them that the account will be automatically deleted if they don't reply within some period.

这篇关于在ASP.NET成员资格提供删除具有重复的电子邮件用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆