Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...How to enter 300 username/passwords more easily?How to enter 300 username/passwords more easily?
Previous
 
Next
New Post
6/29/2007 10:00 AM
 

I am developing with VS.NET 2005, and I am using data layer table adapters to interact with my data. So the following shows how I added code to John's code, so to add my users to roles:

'Add towards the end of 'cmdImportUsers_Click'

                If createStatus = UserCreateStatus.Success Then
                    responseBuilder.Append(String.Format("User '{0}' created successfully", oUserInfo.Username))
                    responseBuilder.AppendLine()

                    'and add to my custom role
                    Dim da As New UserProfileTableAdapter
                    Dim daUsers As New UsersTableAdapter
                    Dim i As Integer
                    i = daUsers.GetUserID(GetXmlItemValue(xmlItem, "Username"))
                    'You can retrieve role ids with SP GetRoles
                    'In this case the roleID for my custom role is '3'
                    da.AddUserToRole(0, i, 3)         '(portalId, userId, RoleId)
                    'responseBuilder.Append(String.Format("User '{0}' added to Custom Role "))
                    'responseBuilder.AppendLine()

                Else
                    responseBuilder.Append(String.Format("<br />User '{0}' creation failed: {1}", oUserInfo.Username, [Enum].GetName(GetType(UserCreateStatus), createStatus)))
                End If

 

 

All 'GetUserID' does is :

SELECT UserID
FROM Users
WHERE Username = @Param1

 

And 'AddUserToRole(0, i, 3)' does is call a new SP I created called AddUserRoleNoDate (based on SP AddUserRole)

AddUserRoleNoDate sql is like so:

 

USE [YOURDATABASE]
GO
/****** Object:  StoredProcedure [dbo].[AddUserRoleNoDate]    Script Date: 06/29/2007 09:00:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[AddUserRoleNoDate]

    @PortalId        int,
    @UserId            int,
    @RoleId            int


AS
DECLARE @UserRoleId int

SELECT @UserRoleId = null

SELECT @UserRoleId = UserRoleId
    FROM   dbo.UserRoles
    WHERE  UserId = @UserId AND RoleId = @RoleId
 
IF @UserRoleId IS NOT NULL
    BEGIN

        SELECT @UserRoleId
    END
ELSE
    BEGIN
        INSERT INTO dbo.UserRoles (
            UserId,
            RoleId

          )
        VALUES (
            @UserId,
            @RoleId

          )

    SELECT SCOPE_IDENTITY()
END

 

 

 
New Post
6/29/2007 2:24 PM
 

Thanks, Tigris7, I'll try that.

 
New Post
8/3/2007 11:12 AM
 

 

Hi marksman_002 ,

 I am not sure you solved your issue or not. But dnnvillage released a import export module which is help you to import users in xml format so all you need is convert Spreadsheet data to valid xml file then use the module to import them to the portal. There is some instructions as well as two sample xml files. If you got issue just let me know I will try to help you.This is the address of the module( it is free). Hope it works for you.

http://www.dnnvillage.com

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...How to enter 300 username/passwords more easily?How to enter 300 username/passwords more easily?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out