0

我已经通过以下代码以编程方式编写了用于创建 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。

4

1 回答 1

0

如果选中,请尝试取消选中管理员设置下的“使用电子邮件地址作为用户名”。

于 2016-04-10T16:57:07.890 回答