Authenticate user by ADFS (Active Directory Federation Service)

戏子无情 提交于 2019-12-03 21:39:54

问题


I need to check whether particular user exist OR not in Active Directory by ADFS.

So, I want my ADFS to check user Authentication by UserName/Password.

Could anybody please provide the sample code OR tutorial for the same.

Thanks in advance!


回答1:


To use Username/Password authentication you can use the

trust/13/UsernameMixed

endpoint of the ADFS 2.0.

This does NOT check if the user exists in the Active Directory!

In code you request the token like this:

WSTrustChannelFactory adfsfactory = new WSTrustChannelFactory(new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential),
                            StsEndpoint);

adfsfactory.TrustVersion = TrustVersion.WSTrust13;

// Username and Password here...
factory.Credentials.UserName.UserName = "domain\username";
factory.Credentials.UserName.Password = "password";

IWSTrustChannelContract channel = adfsfactory.CreateChannel();

// request the token
SecurityToken token = channel.Issue(rst);

Then create the channel factory for your service using your token:

var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.Message);

var factory = new ChannelFactory<IYourInterface >(binding, "your service address");

factory.ConfigureChannelFactory();

IYourInterface channel = factory.CreateChannelWithIssuedToken(token);

Hope this helps!




回答2:


The AD FS 2.0 sign-in pages support username/password authentication out of the box. No code or customizations necessary.




回答3:


As per @Marnix, this is out the box behavior.

However, just to point out:

Authenticating the user is NOT the same as checking whether a particular user exists in Active Directory.

e.g. the user could be locked out. He still exists in AD but will not be able to authenticate.



来源:https://stackoverflow.com/questions/10651304/authenticate-user-by-adfs-active-directory-federation-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!