Last active
November 9, 2018 04:42
-
-
Save MarneeDear/83fc7e142063ae3e631f612856261611 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In my MVC apps I put this in the Startup.Auth file | |
//Inside | |
//public void ConfigureAuth(IAppBuilder app) | |
var edsClient = | |
new DirectoryServices.EdsClient(appSettings["Eds.Server.Url"], appSettings["Eds.Username"], | |
appSettings["Eds.Password"]) as Interfaces.IEdsClient; | |
var casOptions = new CasAuthenticationOptions | |
{ | |
AuthenticationType = "Net ID", // change "CAS" to "Net ID" on the button and in DB | |
Caption = "Net ID", // change "CAS" to "Net ID" in tool tip | |
CasServerUrlBase = appSettings["Cas.Server.Url"], | |
Provider = new CasAuthenticationProvider | |
{ | |
OnAuthenticated = context => | |
{ | |
var userInfo = edsClient.GetUserInfo(context.Identity.Name); | |
foreach (var attr in userInfo.Attributes) | |
{ | |
foreach (var val in attr.Values) | |
{ | |
context.Identity.AddClaim(new Claim(attr.Name, val)); | |
} | |
} | |
return Task.FromResult(0); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment