简体   繁体   English

进行主动身份验证时,转换ADFS中的传入用户名声明

[英]Transforming incoming username claim in ADFS when doing active authentication

I'm attempting to authenticate to an ADFS server via active federation, but need to transform the incoming username via an AD/LDAP query before attempting to authenticate the user. 我正在尝试通过主动联盟对ADFS服务器进行身份验证,但是在尝试对用户进行身份验证之前,需要通过AD / LDAP查询转换传入的用户名。

I'm using the UsernameMixed endpoint with a UserNameWSTrustBinding: 我正在将UsernameMixed端点与UserNameWSTrustBinding一起使用:

WSTrustChannelFactory factory = new WSTrustChannelFactory(new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential), "https://nobody.com/adfs/services/trust/13/UsernameMixed");          

factory.TrustVersion = TrustVersion.WSTrust13;
factory.Credentials.UserName.UserName = userName;
factory.Credentials.UserName.Password = password;

IWSTrustChannelContract channel = factory.CreateChannel();
RequestSecurityToken rst = new RequestSecurityToken(RequestTypes.Issue, WSTrust13Constants.KeyTypes.Bearer);
SecurityToken token = channel.Issue(rst);

My problem is, I want to transform the "username" passed to the endpoing to the user's email address (via AD or LDAP) on the ADFS server before running authentication. 我的问题是,在运行身份验证之前,我想将传递给终端的“用户名”转换为ADFS服务器上用户的电子邮件地址(通过AD或LDAP)。 Is this possible to do? 这可能吗?

As far as I know, there's no simple way on the AD FS server to transform the incoming username before doing authentication. 据我所知,在执行身份验证之前,AD FS服务器上没有简单的方法来转换传入的用户名。 The transformations are done on outgoing claims after authentication has already happened. 身份验证已经发生后,将对传出的声明进行转换。

You'll probably need to query AD/LDAP in your relying party application to get this information. 您可能需要在依赖方应用程序中查询AD / LDAP以获得此信息。 Do something like this (taken from here ): 做这样的事情(从这里获取 ):

string domain = "YourDomain";

List<string> emailAddresses = new List<string>();

PrincipalContext domainContext = new PrincipalContext(ContextType.Domain, domain);
UserPrincipal user = UserPrincipal.FindByIdentity(domainContext, userName);

// Add the "mail" entry
emailAddresses.Add(user.EmailAddress);

// Add the "proxyaddresses" entries.
PropertyCollection properties = ((DirectoryEntry)user.GetUnderlyingObject()).Properties;
foreach (object property in properties["proxyaddresses"])
{
   emailAddresses.Add(property.ToString());
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过WIF在ADFS中进行用户名/密码验证 - Username/passwd authentication in ADFS through WIF 从 ADFS 声明授权 - Claim auth from ADFS ADFS和LiveID-电子邮件声明不属于声明 - ADFS and LiveID - email claim not part of the claim ADFS Active Authentication .NET 4.5(后WIF) - ADFS Active Authentication .NET 4.5 (Post-WIF) 使用 Azure AD 的用户名和密码进行本地 ADFS 身份验证(SharePoint-Online) - On-Prem ADFS Authentication with username and password to Azure AD (SharePoint-Online) 使用Windows身份验证时如何保留自定义声明 - How to persist custom claim when using windows authentication 在其他浏览器中打开登录网站时,adfs身份验证失败 - adfs authentication failed when open logged in website in different browser 基于“System.Security.Principal”的 c# 用户身份验证是否适用于 ADFS 和 Azure Active Directory? - Does c# user authentication based on “System.Security.Principal” works for ADFS and Azure Active Directory? 使用 Web 服务在 ADFS 中进行身份验证 - Authentication in ADFS with Web Service 名称声明返回用户名而不是名称 - Name claim returning username and not name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM