开发者

How can I mass generate Usernames, Passwords, and simple profile info to load into ASPNETDB?

I have an existing database with an accountnumber. I want to create a script that will take that column as input and generate for each accountnumber a username/password/profile entry.

The profile entry would be the original account number.

So, for example assume I use accountnumber for user/pass as well...

This is what I Logically want to do

insert into ASPNETDB Select accountnumber, accountnumber as UserName, accountnumber as Password, accountnumber as profileentry from table1

开发者_StackOverflow

I know that creating 1 user requires the use of some stored procs, that's why I'm not sure how to do this.


Well I can reply this from asp.net c# point of view. Create an aspx page and in the code-behind, use a loop to read each record(accountnumber) and create the user inside the loop using CreateUser() method of membership class.

Something like:

loop start{

      // read account number from existing table
      CreateUser(acccountnumber,password);

}

To know about programmatically creating a user using CreateUser method check this:

Programmatically creating a user


Here it is, I just reread the MS documentation and just went for it. This sets up a user account and generates a key profile value for each record.

declare @PPID NVARCHAR(20)
declare @salt NVARCHAR(500)
declare @stupid NVARCHAR(500)
declare @UserId uniqueidentifier
declare cur CURSOR LOCAL for 
select PPID from webData..table where PPID is not null

open cur 

fetch next from cur into @PPID

while @@FETCH_STATUS = 0 BEGIN 
set @salt = @PPID + @PPID 
set @stupid = 'TangiblePropertyId:S: 0:'  + CONVERT(VARCHAR(10),LEN(@PPID))
    --execute your sproc on each row 
   exec [aspnetdb].[dbo].[aspnet_Membership_CreateUser] '/',
  @PPID
  ,@PPID
  ,@PPID
  ,@salt
  ,null
  ,null
  ,1
  ,'01/01/2011'
  ,DEFAULT
  ,DEFAULT
  ,DEFAULT
  ,@UserID

    exec dbo.aspnet_UsersInRoles_AddUsersToRoles '/',@PPID,'TaxPayer','01/01/2011'
EXECUTE  [aspnetdb].[dbo].[aspnet_Profile_SetProperties]  '/' , @stupid ,@PPID  ,''  ,@PPID  ,false  ,'01/01/2011'

PRINT @stupid

    fetch next from cur into @PPID 
END 

close cur 
deallocate cur 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜