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 ...
随机推荐
- upc组队赛16 Winner Winner【位运算】
Winner Winner 题目链接 题目描述 The FZU Code Carnival is a programming competetion hosted by the ACM-ICPC Tr ...
- Codeforces Round #285 (Div. 2)C. Misha and Forest(拓扑排序)
传送门 Description Let's define a forest as a non-directed acyclic graph (also without loops and parall ...
- 第五周课程总结&实验报告三
1.已知字符串:"this is a test of java".按要求执行以下操作:(要求源代码.结果截图.) •统计该字符串中字母s出现的次数. •统计该字符串中子串" ...
- 16、NumPy ——字节交换
NumPy 字节交换 在几乎所有的机器上,多字节对象都被存储为连续的字节序列.字节顺序,是跨越多字节的程序对象的存储规则. 大端模式:指数据的高字节保存在内存的低地址中,而数据的低字节保存在内存的高地 ...
- 01 spring循环依赖
作者:Mythsman原文:https://blog.mythsman.com/post/5d838c7c2db8a452e9b7082c/转载自:猿天地原文来自:https://mp.weixin. ...
- 天堂Lineage(單機版)從零開始架設教學 Installing Lineage 3.52 Server - On Windows
1. [下載原始碼] Using RapidSVN 用checkout http://l1j-tw-99nets.googlecode.com/svn/trunk/L1J-TW_3.50 ...
- python学习第三十六天命名空间的概念
python命名空间也叫名字空间,也叫名称空间,任何编程语言都有命名空间,大体意思都一样,定义文件所在的目录,下面详细讲述命名空间几种情况 1,locals: 是函数内的名称空间,包括局部变量和形参 ...
- Ajax —— 服务器端发送JSON数据
重点需要解决的问题:服务器端如何构建JSON数据 思考:JavaBean转JSON数据,集合转JSON数据,普通java对象(String,Number)转JSON数据 一.Gson开源jar包 ...
- art-template补充
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8& ...
- elasticsearch 深入 —— 结构化搜索
结构化搜索 结构化搜索(Structured search) 是指有关探询那些具有内在结构数据的过程.比如日期.时间和数字都是结构化的:它们有精确的格式,我们可以对这些格式进行逻辑操作.比较常见的操作 ...