会员资格:如何设置用户ID为整数:S和不加密 [英] Membership : How to set userID to integer :S and not encrypted

查看:141
本文介绍了会员资格:如何设置用户ID为整数:S和不加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CREATE TABLE [dbo].[aspnet_Membership](
 [ApplicationId] [uniqueidentifier] NOT NULL,
 [UserId] [uniqueidentifier] NOT NULL,

有没有简单的方法来使用和整型值作为用户名(不是这个加密...)

Is there any easy ways to use and integer value as UserID (not this encrypted ...)

我真的需要整数: - /

I really need integer :-/

推荐答案

您可以写一个简单的自定义的成员提供使用数据库,而不是默认的ASP.NET之一。

You could easily write a custom membership provider that uses your database rather than the default ASP.NET one.

这是最主要的原因微软走下提供者模型,他们已经提供了你需要实现一个接口,然后将其他工具(UI,访问控制等),可以用它所有的工作。

This is the main reason Microsoft went down the provider model, they have supplied an interface that you need to implement, and then the other tools (UI, access controls, etc) can all work with it.

一个示例实现可以在MSDN上找到:

A sample implementation can be found on MSDN:

如何:样品成员提供者实现

您会注意到<一href=\"http://msdn.microsoft.com/en-us/library/system.web.security.membershipuser.provideruserkey.aspx\"相对=nofollow> ProviderUserKey 上的 的MembershipUser是一个对象,而不是一个GUID,这样你就可以使用int,字符串,或任何会为你。

You'll notice that the ProviderUserKey on the MembershipUser is an Object, not a GUID, so you can use an Int, String, or whatever does it for you.

另一个选择是将存储在用户的这个链接配置文件,然​​后从那里做了相关查询,但不会像干净。

Another option would be to store this link in the users Profile, and then do the relevant lookups from there, but that wouldn't be as clean.

修改回应置评

嗯,这取决于你想要做的工作实在。如果你很高兴来复制你的SQL数据库ASP.NET成员的存储过程,你可以用创建一个类(如样品)从的MembershipProvider 继承,只有闪避提供 CREATEUSER 方法来创建一个基于整数键,而不是基于GUID一个覆盖。

Well, it depends on where you want to do the work really. If you are happy to replicate the ASP.NET Membership stored procedures in your SQL database, you could get away with creating a class that (like the sample) inherits from MembershipProvider and only provide an override of the CreateUser method to create an integer based key, rather than a GUID based one.

基本上,样品是显示你一个成员提供一个完整的实现 - 所有这些方法在很多中的MembershipProvider以同样的方式来实现的,在覆盖关键字方法和属性告诉框架使用我的方法,而不是基类的方法,请。

Basically, the sample is showing you a complete implementation of a membership provider - all of those methods are implemented in much the same way in MembershipProvider, the override keyword on the methods and properties is telling the framework "Use my methods instead of the base class methods please".

这篇关于会员资格:如何设置用户ID为整数:S和不加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆