手动将用户添加到数据库 ASP.NET?

发布于 2024-09-05 20:59:07 字数 231 浏览 2 评论 0原文

因此,当您使用 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 技术交流群。

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

发布评论

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

评论(2

梦幻之岛 2024-09-12 20:59:08

正如 Frank 所说,您应该使用 MembershipProvider 接口。

直接回答你的问题,99% 的可能性该数字只是一个 GUID。获得一个就像这样简单:

string idText = System.Guid.NewGuid().ToString();

编辑:只是为了说清楚,我不推荐这样做。如果您不使用正确的 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:

string idText = System.Guid.NewGuid().ToString();

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.

南街九尾狐 2024-09-12 20:59:08

下载 .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.

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