How to: Use a Custom User Name and Password Validator(WCF)
在wcf中使用自定义的用户名和密码验证方式
https://msdn.microsoft.com/en-us/library/aa702565.aspx
http://www.codeproject.com/Articles/96028/WCF-Service-with-custom-username-password-authenti
To configure a service to use a custom user name and password validator
Configure a binding that uses message security over any transport or transport-level security over HTTP(S).
When using message security, add one of the system-provided bindings, such as a <wsHttpBinding>, or a <customBinding> that supports message security and the UserName credential type.
When using transport-level security over HTTP(S), add either the <wsHttpBinding> or <basicHttpBinding>, a <netTcpBinding> or a <customBinding> that uses HTTP(S) and the Basic authentication scheme.
Note When .NET Framework version 3.5 or later is used, you can use a custom username and password validator with message and transport security. With WinFX, a custom username and password validator can only be used with message security.
Tip For more information on using <netTcpBinding> in this context, see <security> of <netTcpBinding>
In the configuration file, under the <system.serviceModel> element, add a <bindings> element.
Add a <wsHttpBinding> or <basicHttpBinding> element to the bindings section. For more information about creating an WCF binding element, see How to: Specify a Service Binding in Configuration.
Set the mode attribute of the <security> of <wsHttpBinding> or <security> of <basicHttpBinding> to Message, Transport, or TransportWithMessageCredential.
Set the clientCredentialType attribute of the <message> of <wsHttpBinding> or <transport> of <wsHttpBinding>.
如果第3步使用的是Security是Message,那么就设置MessageSecurity的MessageClientCredentialType为UserName
When using message security, set the clientCredentialType attribute of the <message> of <wsHttpBinding> to UserName.
When using transport-level security over HTTP(S), set the clientCredentialType attribute of the <transport> of <wsHttpBinding> or <transport> of <basicHttpBinding> to Basic.
Note |
---|
When a WCF service is hosted in Internet Information Services (IIS) using transport-level security and the UserNamePasswordValidationMode property is set to Custom, the custom authentication scheme uses a subset of Windows authentication. That is because in this scenario, IIS performs Windows authentication prior to WCF invoking the custom authenticator. |
For more information about creating an WCF binding element, see How to: Specify a Service Binding in Configuration.
The following example shows the configuration code for the binding.
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="Binding1">
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
netTcpBinding的security的Mode属性,可以设置为4种类型,选择Message
2.Configure a behavior that specifies that a custom user name and password validator is used to validate user name and password pairs for incoming UserNameSecurityToken security tokens.
As a child to the <system.serviceModel> element, add a <behaviors> element.
Add a <serviceBehaviors> to the <behaviors> element.
Add a <behavior> of <serviceBehaviors> element and set the name attribute to an appropriate value.
Add a <serviceCredentials> to the <behavior> of <serviceBehaviors> element.
Add a <userNameAuthentication> to the <serviceCredentials>.
Set the userNamePasswordValidationMode to Custom.
Important If the userNamePasswordValidationMode value is not set, WCF uses Windows authentication instead of the custom user name and password validator.
Set the customUserNamePasswordValidatorType to the type that represents your custom user name and password validator.
The following example shows the <serviceCredentials> fragment to this point.
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Microsoft.ServiceModel.Samples.CalculatorService.CustomUserNameValidator, service" />
</serviceCredentials>
How to: Use a Custom User Name and Password Validator(WCF)的更多相关文章
- How to: Use a Custom User Name and Password Validator
在wcf中使用自定义的用户名和密码验证方式 https://msdn.microsoft.com/en-us/library/aa702565.aspx http://www.codeproject. ...
- 【ASP.NET Identity系列教程(一)】ASP.NET Identity入门
注:本文是[ASP.NET Identity系列教程]的第一篇.本系列教程详细.完整.深入地介绍了微软的ASP.NET Identity技术,描述了如何运用ASP.NET Identity实现应用程序 ...
- P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1
P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1 May ...
- 优秀的PHP开源项目集合
包管理Package Management Package Management Related 框架 框架组件 微框架Micro Frameworks 内容管理系统Content Managemen ...
- SSL构建单双向https认证
1. SSL基本介绍 我们常常在使用网上银行时看到的连接都是以“https”开始的,那么这个https是什么呢?这其实是表示目前连接使用了SSL进加密,能保证客户端到服务器端的通信都在被保护起来,那 ...
- PHP框架、库和软件资源大全(整理篇)
php的资料 https://github.com/ziadoz/awesome-php Awesome PHP A curated list of amazingly awesome PHP lib ...
- Bootstrap风格登录界面设计样例
参考:http://bootsnipp.com/tags/login Register Page 127.8K 187 Modal Login with jQuery Effects 159. ...
- ios swift模仿qq登陆界面,xml布局
给大家推荐两个学习的地址: 极客学院的视频:http://www.jikexueyuan.com/path/ios/ 一个博客:http://blog.csdn.net/lizhongfu2013/a ...
- FNDCPASS Troubleshooting Guide For Login and Changing Applications Passwords
In this Document Goal Solution 1. Error Starting Application Services After Changing APPS Pass ...
随机推荐
- 【Unity知识点】安卓游戏如何在切后台后继续运行
解决方法很简单,在android项目AndroidManifest.xml文件中的activity中添加如下内容: android:configChanges="fontScale|keyb ...
- hihoCoder 1014 : Trie树(字典树)
传送门 Description 小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助,在编程的学习道路上一同前进. 这一天,他们遇到了一本词典,于是小Hi就向小 ...
- 有用的官方API和官网
1.Bootstrap API:http://www.runoob.com/bootstrap/bootstrap-tutorial.html 2.百度地图API示例:http://lbsyun.ba ...
- JSP基础--三大指令
JSP指令 1 JSP指令概述 JSP指令的格式:<%@指令名 attr1=”” attr2=”” %>,一般都会把JSP指令放到JSP文件的最上方,但这不是必须的. JSP中 ...
- python中进程池和回调函数
一.数据共享 1.进程间的通信应该尽量避免共享数据的方式 2.进程间的数据是独立的,可以借助队列或管道实现通信,二者都是基于消息传递的. 虽然进程间数据独立,但可以用过Manager实现数据共享,事实 ...
- jvm学习(5) 对象的创建与结构
上图表明:jvm虚拟机位于操作系统的堆中,并且,程序员写好的类加载到虚拟机执行的过程是:当一个classLoder启动的时候,classLoader的生存地点在jvm中的堆,然后它会去主机硬盘上将A. ...
- k8s 组件介绍-kube-schedule
kubernetes scheduler 基本原理 kubernetes scheduler 作为一个单独的进程部署在 master 节点上,它会 watch kube-apiserver 进程去发现 ...
- [fw]linux 下如何查看和踢除正在登陆的其它用户
linux 下如何查看和踢除正在登陆的其它用户 Posted on 2011/09/01 如何在linux下查看当前登录的用户,并且踢掉你认为应该踢掉的用户?请使用who这个命令来查看当前正在登录 ...
- CodeChef Mahesh and his lost array
Mahesh and his lost array Problem code: ANUMLA Submit All Submissions All submissions for this ...
- mysql处理重复数据仅保留一条记录
目的:去除(或删除)一个表里面手机号重复的数据,但是需要保留其中一个记录,换句话说,表里面手机号不为空的数据,一个手机有且只有一条记录 表结构: CREATE TABLE `account` ( `i ...