public void InitializeBrokerProvider() //amit 18052017 { try { brokerMemProvider = new BrokerMembershipProvider(); System.Web.Security.SqlMembershipProvider ObjSqlMembershipProvider = new System.Web.Security.SqlMembershipProvider(); System.Web.Security.SqlRoleProvider ObjSqlRoleProvider = new System.Web.Security.SqlRoleProvider(); System.Collections.Specialized.NameValueCollection ObjNameValueCollRole = new System.Collections.Specialized.NameValueCollection(); System.Collections.Specialized.NameValueCollection ObjNameValueCollMembership = new System.Collections.Specialized.NameValueCollection(); System.Web.Security.MembershipCreateStatus enMembershipCreateStatus; ObjNameValueCollMembership.Add("connectionStringName", "SqlMembershipConn"); ObjNameValueCollMembership.Add("applicationName", "AMS.Broker.WatchDogService"); //these items are assumed to be Default and dont care..Should be given a look later stage. ObjNameValueCollMembership.Add("enablePasswordRetrieval", "false"); ObjNameValueCollMembership.Add("enablePasswordReset", "false"); ObjNameValueCollMembership.Add("requiresQuestionAndAnswer", "false"); ObjNameValueCollMembership.Add("requiresUniqueEmail", "false"); ObjNameValueCollMembership.Add("passwordFormat", "Hashed"); ObjNameValueCollMembership.Add("maxInvalidPasswordAttempts", "5"); ObjNameValueCollMembership.Add("minRequiredPasswordLength", "1"); ObjNameValueCollMembership.Add("minRequiredNonalphanumericCharacters", "0"); ObjNameValueCollMembership.Add("passwordAttemptWindow", "10"); ObjNameValueCollMembership.Add("passwordStrengthRegularExpression", ""); // ObjSqlMembershipProvider.Initialize("AspNetSqlMembershipProvider", ObjNameValueCollMembership); //System.Web.Security.MembershipUser user = ObjSqlMembershipProvider.CreateUser("admin,"password","*****@*****.**"); //hard coded the Provider Name,This function just need one that is present. I tried other names and it throws error. I found this using Reflector ..all the rest are take care by the above //name value pairs brokerMemProvider.Initialize("BrokerMembershipProvider", ObjNameValueCollMembership); } catch (Exception ex) { } }
protected void Button1_Click(object sender, EventArgs e) { //System.Web.Security.Roles.CreateRole("TestRole"); System.Web.Security.SqlMembershipProvider smp = new System.Web.Security.SqlMembershipProvider(); //smp.Initialize("", System.Web.Security.SqlRoleProvider srp = new System.Web.Security.SqlRoleProvider(); var nvc = new System.Collections.Specialized.NameValueCollection(); nvc.Add("connectionStringName", "DefaultConnection"); nvc.Add("applicationName", "at"); srp.Initialize("DefaultRoleProvider", nvc); srp.CreateRole("atTest5"); System.Web.Security.Roles.CreateRole("TestRole1"); }