我有一个新的DNN网站和一长串必须添加的用户。如何使用脚本创建这些新用户。
我已经看过销售的模块但是如果可能的话我想避免购买模块。
答案 0 :(得分:2)
对于仍在搜索开源模块以导入用户的任何人,有一个http://usersimporter.codeplex.com/适用于最新的DNN版本。它需要一个Excel电子表格作为输入。
答案 1 :(得分:0)
我正在使用DNN 4.4和4.9并遇到同样的问题。我的解决方案是为此开发一个DNN模块,可以从CSV或TAB分离的文本文件导入。我的建议是购买或开发模块。
如果你有兴趣写自己的话,我可以为你提供代码片段。请告诉我......
答案 2 :(得分:0)
Snowcovered有一些内置模块 - (http://www.snowcovered.com/snowcovered2/Default.aspx?tabid=295&search=import+user) -
我还编写过脚本来从一个或另一个电子表格或其他数据库中执行此操作
执行此操作的sql脚本实际上只需要添加正确的信息
继承人大多数我用来从某些访问dbs导入的脚本 - 可能不是很好或优雅但它有效!
SET NOCOUNT ON;
declare @SQLText nvarchar(max)
DECLARE @ErrMsg nvarchar(4000), @ErrSeverity int
BEGIN TRY
BEGIN TRANSACTION
-- Insert statements for procedure here
DECLARE @ApplicationName nvarchar(256)
SET @ApplicationName = 'DotNetNuke'
DECLARE @LastName nvarchar(max)
DECLARE @FirstName nvarchar(max)
DECLARE @EmployeeID nvarchar(max)
DECLARE @ContactEmail nvarchar(max)
DECLARE UserLoop CURSOR Fast_Forward
FOR SELECT [Employee] as EmployeeID, isnull([LastName],'') as employee_Lastname, isnull([FirstName],'') as emplyee_firstname, 'na@na.com' as contactemail
from openrowset('Microsoft.ACE.OLEDB.12.0', 'Excel 8.0;Database=C:\_projects\hc.xls;HDR=YES', 'SELECT * FROM [Sheet1$]')
--WHERE CustomerID in (SELECT OldID FROM dbo.RCIWebApps_LocationInfo WHERE OwnerID = @NewCustomerNumber)
Open UserLoop
FETCH NEXT FROM UserLoop INTO @EmployeeID, @LastName, @FirstName, @ContactEmail
WHILE @@FETCH_STATUS = 0
BEGIN
----
---Make unique usernames - adding one to the list until it doesnt match
DECLARE @NewUsername nvarchar(max)
SET @NewUserName = REPLACE(@Firstname + '_' + @LastName, ',','_')
DECLARE @UserNameTest int
SET @UsernameTest = 1
DECLARE @UserNameNumber int
SET @UserNameNumber = 1
DECLARE @UserNameTemp nvarchar(max)
SET @UserNameTemp = @NewUserName
WHILE @UserNameTest > 0
BEGIN
SELECT @UsernameTest = count(*) FROM rcidnn..Users WHERE Username = @UserNameTemp
IF @USernametest > 0
BEGIN
SET @UsernameTemp = @NewUserName + convert(nvarchar(max),@UserNameNumber)
SET @UserNameNumber = @UserNameNumber + 1
END
END
SET @NewUserName = @UserNameTemp
----
DECLARE @Password nvarchar(128)
--From the existing user
SET @Password = 'iIFBTBSKXithnIDFau1miTih903eL/z5qgbcyMOflIM='
DECLARE @PasswordSalt nvarchar(128)
--From the existing user
SET @PasswordSalt = '4DmxPzt6MYScaGuwNHeUDw=='
DECLARE @PasswordQuestion nvarchar(256)
SET @PasswordQuestion = ''
DECLARE @PasswordAnswer nvarchar(128)
SET @PasswordAnswer = ''
DECLARE @IsApproved bit
SET @IsApproved = 1
DECLARE @CurrentTimeUtc datetime
SET @CurrentTimeUtc = GETDATE()
DECLARE @CreateDate datetime
SET @CreateDate = @CurrentTimeUtc
DECLARE @UniqueEmail int
SET @UniqueEmail = 0
DECLARE @PasswordFormat int
SET @PasswordFormat = 2 --NOTE: Value from existing user!
DECLARE @PortalId int
SET @PortalId = 6 --The id of your portal
Declare @UserId uniqueidentifier
DECLARE @DNNUserId int
--Make the stored procedure call
EXEC rcidnn.dbo.aspnet_Membership_CreateUser @ApplicationName, @NewUsername, @Password,
@PasswordSalt, @contactemail, @passwordquestion, @PasswordAnswer,
@IsApproved, @CurrentTimeUtc, @CreateDate, @UniqueEmail,
@PasswordFormat, @UserId
--Insert the record into the DotNetNuke users table
print @NewUsername
INSERT INTO rcidnn..users (Username, FirstName, LastName, IsSuperUser, Email,
DisplayName, UpdatePassword)
VALUES(@NewUsername, @FirstName, @LastName, 0, @ContactEmail, @Firstname + ' ' + @LastName, 0)
--Get the new userid, from the DNN users table
SELECT @dnnuserid = userid
FROM rcidnn..Users
WHERE username = @NewUsername
--Now, insert the record into the user portals table
INSERT INTO rcidnn..UserPortals (userId, PortalId, CreatedDate)
VALUES(@dnnuserid, @PortalId, GETDATE())
--Now Give the user permissions to the RECISTERED Users group
INSERT INTO rcidnn..UserRoles (userId, roleId)
SELECT @dnnuserid,
roleId
FROM rcidnn..Roles
WHERE (RoleName = 'Registered Users' or RoleName = 'Subscribers' or RoleName = 'G - Location View')
and portalid = @PortalId
--ADD info into profile??
INSERT rcidnn.dbo.UserProfile
VALUES ( @DNNUserID, 167, @NewCustomerNumber, null, 2, getdate())
----
FETCH NEXT FROM UserLoop INTO @EmployeeID, @LastName, @FirstName, @ContactEmail
END
CLOSE Userloop
DEALLOCATE userloop
COMMIT
Print 'Transfered'
END TRY
BEGIN CATCH
-- Whoops, there was an error
IF @@TRANCOUNT > 0
ROLLBACK
-- Raise an error with the details of the exception
SELECT @ErrMsg = ERROR_MESSAGE(),
@ErrSeverity = ERROR_SEVERITY()
RAISERROR(@ErrMsg, @ErrSeverity, 1)
END CATCH
答案 3 :(得分:0)
我很幸运使用此模块导入用户。 DNNVillage Import Export User Pro它使用易于修改的XML文件导入和导出用户。如果您使用excel将用户列表插入xml文件然后导入它,那么您应该很高兴。最好的部分是该模块是免费的。
答案 4 :(得分:0)
我使用过的最好的产品是“批量用户管理器”。不是免费的,但值得30美元。它将节省数小时的工作,而时间就是金钱! 以下是DNN商店中产品的链接: http://store.dnnsoftware.com/home/product-details/bulk-user-manager-v33