启用和禁用用户帐户 [英] Enable and disable user accounts
本文介绍了启用和禁用用户帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!
我在数据库中有一个简单的表.其中包含用户帐户信息.
userid,密码,FirstName,LastName,地址
我想禁用并启用它..以便当我禁用它时..帐户持有人无法登录,而当我启用它时..然后他可以登录.
Hi!
I have a simple table in the database. which have the user account information.
userid , password, FirstName , LastName ,Address
i want to disable and enable it.. so that when i disable it.. account holder can''t be able to login and when i enable it.. then he can login.
推荐答案
为此,您需要更改包含用户详细信息的表,
您需要再添加一个列名(如status)并输入bit并将其设置为默认值1
在这里,当状态为1时,表示用户处于活动状态,表示他/她可以登录;或者,在禁用状态时,将其设置为0,则表示该用户无法登录..
要应用此机制,您可以像这样在用户登录查询中添加一个条件
SELECT * FROM USERDETAIL,其中USERNAME = @USERNAME和密码= @PASSORD AND STATUS = 1
如果它将返回记录,则用户将通过身份验证,否则未通过..
用于禁用用户,您可以触发这样的查询
UPDATE USERDETAIL SET STATUS = 0 WHERE USERNAME = @USERNAME
For this you need to change your table that will contains user detail,
you need to add one more column name like status and type bit and set it with default value 1
here when status is 1 then the user is active means he/she can login, or when you deactivate means set it with 0 then that use can not login..
for apply this mechanism you can add one condition at your user login query like this
SELECT * FROM USERDETAIL WHERE USERNAME = @USERNAME AND PASSWORD = @PASSORD AND STATUS = 1
if it will return record then the user will authenticated else it is not..
for disabling user you can fire a query like this
UPDATE USERDETAIL SET STATUS = 0 WHERE USERNAME = @USERNAME
我有一个用户管理系统和一个管理员来控制它
I have a user management system and the admin to control it
所以您忘了告诉我们您正在使用什么用户管理系统.我们会想到一些问题,在我们继续进行之前,您应该先回答这些问题.
- 您正在使用什么用户管理系统
- 您在说什么管理员?
- 这是某种ASP.net控件还是库?
- What user management system are you using
- What is this admin you are talking about?
- Is this some sort of ASP.net control or a library?
So you forgot to tell us what user management system you are using. A couple of questions spring to mind which you should answer before we can proceed here.
我不确定您可以使用什么项目,但是可以使用SQL触发器进行启用和禁用操作,可以尝试使用此链接可能会帮助您....
http://msdn.microsoft.com/en-us/library/ms189748.aspx [ ^ ]
一切顺利
I don''t know exactly what you can use your project but you can use SQL triggers for enable and disable possible you can try this link it may help you....
http://msdn.microsoft.com/en-us/library/ms189748.aspx[^]
All the best
这篇关于启用和禁用用户帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文