我已通过以下代码以编程方式编写用于创建DNN用户的代码,但它正在插入类似此50c5c87e-bba7-4fc8-b2b4-1d9e3e388dc5-contracthiring@outlook.com
的用户名。它看起来像是合并GUID + EmailAddress。但它应该是li_ + FirstName + LastName
,因为我通过以下代码动态创建。
我在&之后写了用户名日志在下线之前。这看起来很奇怪。以下是我的输出。
'Response.Write("objUserInfo Before: " & objUserInfo.Username)
objUserCreateStatus = objMembershipProvider.CreateUser(objUserInfo)
'Response.Write("objUserInfo: " & objUserInfo.Username)
用户名输出:
之前:li_Andrea Simon
之后:50c5c87e-bba7-4fc8-b2b4-1d9e3e388dc5-contracthiring@outlook.com
我的代码:
Try
If MySettings("LinkedinUserNamePrefix") <> "" Then
fsUsername = MySettings("LinkedinUserNamePrefix") & objPerson.Firstname & " " & objPerson.Lastname
Else
fsUsername = objPerson.Firstname & " " & objPerson.Lastname
End If
Catch
End Try
'Register user to the site
Dim objUserInfo As New DotNetNuke.Entities.Users.UserInfo
objUserInfo.PortalID = Me.PortalId
objUserInfo.Username = fsUsername
objUserInfo.FirstName = fName
objUserInfo.LastName = lName
objUserInfo.Email = EmailAdd
objUserInfo.DisplayName = fsUsername
objUserInfo.Membership.Username = fsUsername
objUserInfo.Membership.Email = EmailAdd
objUserInfo.Membership.Password = fsUsername
' User Profile
objUserInfo.Profile.PreferredLocale = PortalSettings.DefaultLanguage
objUserInfo.Profile.FirstName = fName
objUserInfo.Profile.LastName = lName
'Set Membership
objUserInfo.Membership.Approved = True
'Bind membership to user
objUserInfo.IsSuperUser = False
Dim objUserCreateStatus As UserCreateStatus = UserCreateStatus.AddUser
Dim objMembershipProvider As DotNetNuke.Security.Membership.MembershipProvider = DotNetNuke.Security.Membership.MembershipProvider.Instance()
'Response.Write("objUserInfo Before: " & objUserInfo.Username)
objUserCreateStatus = objMembershipProvider.CreateUser(objUserInfo)
'Response.Write("objUserInfo: " & objUserInfo.Username)
CreateUser方法有什么问题。它在DNN库中是否存在问题。
我使用的是DNN 07.04.00。
答案 0 :(得分:0)
如果选中,请尝试取消选中管理员设置下的“使用电子邮件地址作为用户名”。