扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:sam1111 来源:aspcool 2007年11月8日
关键字: Windows
namespace System.Configuration.Provider { public interface IProvider { public string Name { get; } public void Initialize(string name, System.Collections.Specialized.NameValueCollection config); } } namespace System.Web.Security { public interface IMembershipProvider { public bool ChangePassword(string name, string oldPwd, string newPwd); public bool ChangePasswordQuestionAndAnswer(string name, string password, string newPwdQuestion, string newPwdAnswer); public System.Web.Security.MembershipUser CreateUser(string username, string password, string email,out System.Web.Security.MembershipCreateStatus status); public bool DeleteUser(string name); public System.Web.Security.MembershipUserCollection GetAllUsers(); public int GetNumberOfUsersOnline(); public string GetPassword(string name, string answer); public System.Web.Security.MembershipUser GetUser(string name,bool userIsOnline); public string GetUserNameByEmail(string email); public string ResetPassword(string name, string answer); public void UpdateUser(System.Web.Security.MembershipUser user); public bool ValidateUser(string name, string password); public string ApplicationName {get; set;} public bool EnablePasswordReset { get;} public bool EnablePasswordRetrieval { get;} public bool RequiresQuestionAndAnswer { get;} } } |
public class MyMembershipProvider : IProvider, IMembershipProvider { …… } |
public bool ValidateUser (string name, string password) { string connectStr = ConfigurationSettings.ConnectionStrings["PortalData"]; SqlConnection myConnection = new SqlConnection (connectStr); SqlCommand myCommand = new SqlCommand ("UserLogin", myConnection); myCommand.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC SqlParameter parameterEmail = new SqlParameter ("@Email", SqlDbType.NVarChar, 100); parameterEmail.Value = name; myCommand.Parameters.Add (parameterEmail); SqlParameter parameterPassword = new SqlParameter ("@Password", SqlDbType.NVarChar, 20); parameterPassword.Value = password; myCommand.Parameters.Add (parameterPassword); SqlParameter parameterUserName = new SqlParameter ("@UserName", SqlDbType.NVarChar, 100); parameterUserName.Direction = ParameterDirection.Output; myCommand.Parameters.Add (parameterUserName); // Open the database connection and execute the command myConnection.Open (); myCommand.ExecuteNonQuery (); myConnection.Close (); if ((parameterUserName.Value != null) && (parameterUserName.Value != System.DBNull.Value)) return true; return false; } |
<connectionStrings> <add name="BugDepotData" connectionString="Data Source=(local);Trusted_Connection=true;Database=Portal" /> </connectionStrings> |
<membership> <providers> <add name="MyMembershipProvider" type="MyMembershipProvider" appName="/" /> </providers> </membership> |
type="ProviderType, Assembly, Version, Culture, PublicKeyToken" |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者