Hello Dave,
As for the ASP.NET SqlMembership provider, if you want to do some database
initialization tasks (such as create some users) out side the ASP.NET
application context), you can manually call the SqlMembershipProvider in
console or winform application. What you need to do is first call
SqlMembershipProvider.Initialize method and passs in the correct name/value
configuration pairs. e.g.
========in winform codebehind=======
public partial class Form1 : Form
{
SqlMembershipProvider _provider = null;
public Form1()
{
InitializeComponent();
}
private void btnCreate_Click(object sender, EventArgs e)
{
MembershipCreateStatus ret;
MembershipUser user = _provider.CreateUser(
txtUsername.Text,
txtPassword.Text,
txtUsername.Text + "@test.org",
"who am i?",
txtUsername.Text, true, null, out ret);
MessageBox.Show(ret.ToString());
}
private void Form1_Load(object sender, EventArgs e)
{
_provider = new SqlMembershipProvider();
NameValueCollection nvc = new NameValueCollection();
XmlDocument doc = new XmlDocument();
doc.LoadXml(txtConfig.Text);
foreach (XmlAttribute attr in doc.DocumentElement.Attributes)
{
nvc.Add(attr.Name, attr.Value);
}
_provider.Initialize(name, nvc );
}
}
==========================
txtconfig.Text is as below
===========
<add name="AspNetSqlMembershipProvider"
connectionStringName="LocalSqlServer" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="true"
applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" />
================
If you feel necessary, I can send you my test winform project. Please feel
free to let me know if you have anything unclear.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.