手动将用户添加到数据库 ASP.NET?
因此,当您使用 ASP.NET 向导创建登录名时,它会使用一组使用 aspnet_regsql.exe 工具自动生成的表...
当您使用向导创建用户时,它会生成一个非常长的用户 ID “a40cf936-1596-4560-a26c-450792e2c8c0”我想使用连接到此数据库的另一个程序添加用户...但是 Visual Studio 如何自动生成此 ID。我也想自动生成它
有什么想法吗?提前致谢。 -斯科特
So when your using ASP.NET Wizards to create a login, it uses a set of auto generated tables using the aspnet_regsql.exe tool...
When you create a user using the wizard it generates a very long userID
"a40cf936-1596-4560-a26c-450792e2c8c0" I want to add users using another program that connects to this database... but how does visual studio auto-generate this ID. I want to auto-generate it as well
Any ideas? Thanks in advance.
-Scott
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 Frank 所说,您应该使用 MembershipProvider 接口。
直接回答你的问题,99% 的可能性该数字只是一个 GUID。获得一个就像这样简单:
编辑:只是为了说清楚,我不推荐这样做。如果您不使用正确的 api 调用,则可能无法正确实现不同表之间的其他依赖关系、权限和角色。您应该查看此处。
As Frank said, you should be using the MembershipProvider interface.
To directly answer your question, 99% chance that number is simply a GUID. To get one is as simple as:
EDIT: Just to make it clear though, I am not recommending this. There are probably other dependencies, rights and roles across different tables that you aren't properly implementing if you don't use the proper api calls. You should look here instead.
下载 .Net Reflector 并查看 AspNetMemembershipProvider 的源代码。您可能可以在那里找到您需要的所有 SQL 调用。此外,我认为您可以在 ASP.NET 之外实例化该类。有一个方法 AspNetMembershipProvider.Initialize(),您可以根据配置文件中的内容调用该方法进行初始化。 Initialize() 的参数并不明显,但是在反射器中反汇编它,你就会明白。
Download .Net Reflector and look at the source for AspNetMemembershipProvider. You can probably find all the SQL calls you need in there. Furthermore, I think you may be able to instantiate the class outside of ASP.NET. There is a method, AspNetMembershipProvider.Initialize(), which you can call to initialize based on what you would have had in the config file. The parameters to Initialize() is not obvious, but disassemble it in reflector and you'll figure it out.