根据域现有的用户名验证来自sql数据库的用户名 [英] Verify username from sql database against domain existing usernames

查看:119
本文介绍了根据域现有的用户名验证来自sql数据库的用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是.net的新手,需要您的帮助专家来完成我的代码.您的帮助将不胜感激.

这是场景:

用户可以使用例如格式注册. name@ourdomain.com.用户名是他们在我们域中的注册名称.除非他们的名字存在于我们的域中,否则将不接受注册.在注册过程中,将根据域中存在的名称验证用户名.我们网域下所有注册名称的列表,例如name@domain.com将从我们的sql数据库中保存.

有人可以帮我吗?

预先感谢任何可以分享的人.

Eddie

I am a newbie in .net and need your help gurus to finalize my code. Your helpf will be much appreciated.

Here is the scenario:

A user can register using the format eg. name@ourdomain.com. Usernames are their registered name in our domain. Registration will not be accepted unless they have their names existed in our domain. During registration, username will be validated against their names existed in the domain. A list of all registered names under our domain eg. name@domain.com will be saved from our sql database.

Can someone help me with this please?

Thanks in advance for anyone who can share.

Eddie

推荐答案

是.仅在针对我们域中存在的用户验证条目后,才能接受用户的注册.
yes.user can be accepted his/her registration after only validating entry against the one existed in our domain.


这可以通过对您的广告使用LDAP查询来实现,

这是一个可以帮助您实现要求的链接

http://www.ianatkinson.net/computing/adcsharp.htm [
This can be achieved using an LDAP Query to your AD,

here is a link which will help you achieve your requirement

http://www.ianatkinson.net/computing/adcsharp.htm[^]


感谢您的回复,但我需要深入了解这一点.实际上,这里是用于登录的代码,但是我需要针对AD中的用户名验证此登录条目.您可以共享您的代码,以便我操纵它来满足我的要求吗?


受保护的无效log_Click(对象发送者,EventArgs e)
{
SqlDataSource sds =新的SqlDataSource();
sds.ConnectionString = ConfigurationManager.ConnectionStrings ["myDbConnectionString1"].ToString();

sds.SelectParameters.Add("username",TypeCode.String,this.username.Text);
sds.SelectParameters.Add("password",TypeCode.String,this.password.Text);

sds.SelectCommand =选择*从[myTb]中[用户名] = @用户名AND [密码] = @密码";

DataView dv =(DataView)sds.Select(DataSourceSelectArguments.Empty);
试试
{
如果(dv.Count == 0)
{
this.lblinfo.ForeColor = System.Drawing.Color.Red;
this.lblinfo.Text =无效的用户名和密码!";
返回;
}
其他
{
FormsAuthentication.RedirectFromLoginPage(username.Text,true);
Response.Redirect("Auth/Upload.aspx");
}
}
赶上
{

}
终于
{

}
}
thanks for your reply but i need to get deep into that. actually here is the code for logging in but i need to verify this login entry against the usernames in AD. can you share your code so i can manipulate it to fit my requirements?


protected void log_Click(object sender, EventArgs e)
{
SqlDataSource sds = new SqlDataSource();
sds.ConnectionString = ConfigurationManager.ConnectionStrings["myDbConnectionString1"].ToString();

sds.SelectParameters.Add("username", TypeCode.String, this.username.Text);
sds.SelectParameters.Add("password", TypeCode.String, this.password.Text);

sds.SelectCommand = "SELECT * FROM [myTb] WHERE [username] = @username AND [password] = @password";

DataView dv = (DataView)sds.Select(DataSourceSelectArguments.Empty);
try
{
if (dv.Count == 0)
{
this.lblinfo.ForeColor = System.Drawing.Color.Red;
this.lblinfo.Text = "Invalid username and password!";
return;
}
else
{
FormsAuthentication.RedirectFromLoginPage(username.Text, true);
Response.Redirect("Auth/Upload.aspx");
}
}
catch
{

}
finally
{

}
}


这篇关于根据域现有的用户名验证来自sql数据库的用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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