这里的参考是我的web.config和代码:
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
<providers>
<clear />
<add name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="MySqlConnection"
applicationName="/"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="true"
passwordFormat="Hashed" />
</providers>
</membership>
VB代码背后的事实:
Public Function Register(ByVal EncryptedName As String, ByVal EncryptedEmail As String) As String
Dim ret As String = ""
Try
Dim Provider As MembershipProvider = Membership.Providers.Item("SqlProvider")
Dim createStatus As MembershipCreateStatus
Dim newUser As MembershipUser = Provider.CreateUser(EncryptedName, Membership.GeneratePassword(8, 1), EncryptedEmail, "Your favorite color?", "RED", True, Guid.NewGuid, createStatus)
Select Case createStatus
Case MembershipCreateStatus.Success
ret = "The user account was successfully created!"
Case MembershipCreateStatus.DuplicateUserName
ret = "There already exists a user with this username."
Case MembershipCreateStatus.DuplicateEmail
ret = "There already exists a user with this email address."
Case MembershipCreateStatus.InvalidEmail
ret = "The email address provided is invalid."
Case MembershipCreateStatus.InvalidAnswer
ret = "The security answer is invalid."
Case MembershipCreateStatus.InvalidPassword
ret = "The password you provided is invalid. It must be seven characters long and have at least one non-alphanumeric character."
Case Else
ret = "There was an unknown error; the user account was NOT created."
End Select
Catch ex As Exception
Return "Server Error."
End Try
Return ret
End Function
为了便于参考,这是一个我们用来允许用户从我们的网站和桌面软件注册的网络服务。我不知道是否是导致此问题的桌面软件。现在我在创建新用户线上遇到异常。例外情况是“DOMAIN /用户登录失败”,其中DOMAIN是我的工作域,用户是我的PC登录工作。
我一直在环顾四周,发现我需要明确告诉使用哪个提供商(提供商检查正常)。我找到了很多人们只使用Membership.CreateUser的样本,但我发现它没有加载正确的登录信息。
我也试过在web.config中使用身份验证标记。
简单的想法是通过Web服务以编程方式注册新用户,以便它可以与网站和多个内部桌面软件应用程序一起使用。
感谢您的帮助。
答案 0 :(得分:0)
成员资格提供程序配置了对连接字符串的引用。你确认它是一个有效的连接字符串吗?这听起来像你使用默认的尝试连接集成身份验证。此外,作为您的PC登录用户告诉我,您正在从调试运行,或者IIS的应用程序池具有明确设置的标识。
这可能无法解决你的问题,但是,我想尽我所能,因为我过去曾有类似的挫败感。