如何批量生成用户名、密码和简单的配置文件信息以加载到 ASPNETDB 中?

发布于 2024-11-25 08:43:51 字数 322 浏览 0 评论 0原文

我有一个带有帐号的现有数据库。我想创建一个脚本,将该列作为输入,并为每个accountnumber生成一个用户名/密码/个人资料条目。

个人资料条目将是原始帐号。

因此,例如假设我也使用帐号作为用户/密码...

这就是我逻辑上想要做的

插入 ASPNETDB 选择帐号,帐号作为用户名,帐号作为密码,帐号as profileentry from table1

我知道创建 1 个用户需要使用一些存储过程,这就是为什么我不确定如何执行此操作。

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

始于初秋 2024-12-02 08:43:51

好吧,我可以从 asp.net c# 的角度来回答这个问题。创建一个 aspx 页面,并在代码隐藏中,使用循环读取每条记录(帐号),并使用会员类的 CreateUser() 方法在循环内创建用户。

例如:

loop start{

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

}

要了解如何使用 CreateUser 方法以编程方式创建用户,请检查以下内容:

以编程方式创建用户

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

浪推晚风 2024-12-02 08:43:51

就是这样,我刚刚重新阅读了 MS 文档,然后就开始了。这将设置一个用户帐户并为每条记录生成一个关键配置文件值。

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 

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 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文