成员资格CreateUser错误 [英] Error with Membership CreateUser
问题描述
我正在以编程方式创建新用户(稍后将添加自定义配置文件),并且正在Win2K8 VM上工作:
I am creating a new user programmatically (will be adding custom profiles later) and am working on Win2K8 VM:
MembershipUser newUser =
Membership.CreateUser(userNameTxt.Text, passwordTxt.Text, emailTxt.Text);
Roles.AddUserToRole(userNameTxt.Text.Trim(), "Member");
更新:
连接字符串:
<remove name="LocalSqlServer" />
<add name="LocalSqlServer"
connectionString="Initial Catalog=MYS;Data Source=WIN2K8;uid=MYS;password=xxxxxx;"
providerName="System.Data.SqlClient" />
出现以下错误:
System.Data.SqlClient.SqlException:用户IIS APPPOOL \ MYAPP'登录失败.
System.Data.SqlClient.SqlException: Login failed for user 'IIS APPPOOL\MYAPP'.
<membership>
<providers>
<remove name="DefaultMembershipProvider"/>
<add
name="DefaultMembershipProvider"
type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
connectionStringName="LocalSqlServer"
enablePasswordRetrieval="false"
enablePasswordReset="false"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<roleManager enabled="true">
推荐答案
您当前的连接字符串是:
You current connection string is this:
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer"
connectionString="Initial Catalog=MYS;Data Source=WIN2K8;Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
</connectionStrings>
这里的错误是您在说:连接到我的sql服务器数据库,并使用应用程序池标识作为帐户"来针对我的sql服务器数据库进行身份验证.
The error here is that you're saying: Connect to my sql server database and use the App Pool identity as the 'account' to authenticate my sql server db against.
IIS上的所有网站都在帐户"下运行.在这种情况下,看起来该帐户称为MyApp
.
All Websits on IIS run under an 'account'. In this case, it looks like this account is called MyApp
.
因此,您需要在连接字符串中注明以下内容:不要使用此IIS计算机上设置的任何标识",等等.但是!请改用此硬编码的用户名/密码.
So the fix you need to have a connection string that says: Don't use whatever 'identity' is setup on this IIS machine, etc. BUT! Use this hardcoded username/password instead.
立即查看此内容
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer"
connectionString="Initial Catalog=MYS;Data Source=WIN2K8;uid=username;password=pass;"
providerName="System.Data.SqlClient" />
</connectionStrings>
注意:
- 我删除了参数:
Integrated Security=SSPI;
- 我添加了参数:
uid=username;
- 我添加了参数:
password=pass;
- I've removed the argument:
Integrated Security=SSPI;
- I've added the argument:
uid=username;
- I've added the argument:
password=pass;
只需将值username
和pass
替换为用于登录sql服务器数据库的用户名/密码即可.
Just replace the values username
and pass
with the username/password you use to log into your sql server database.
需要帮助来了解您可以在单个连接字符串中定义哪些选项/关键字? 选中此ConnectionStrings网站作为参考.
Need help learning about what options/keywords u can define in a single connection string? Check this ConnectionStrings site as a reference.
专业提示:代替<remove name="whatever/>
..尝试使用<clear/>
Pro Tip: Instead of <remove name="whatever/>
.. try using <clear/>
例如
<connectionStrings>
<clear/>
<add name="LocalSqlServer" connectionString="Initial Catalog=MYS;Data Source=WIN2K8;uid=username;password=pass;" providerName="System.Data.SqlClient" />
</connectionStrings>
GL!
这篇关于成员资格CreateUser错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!