Skip to content

Instantly share code, notes, and snippets.

@MarneeDear
Last active November 9, 2018 04:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarneeDear/83fc7e142063ae3e631f612856261611 to your computer and use it in GitHub Desktop.
Save MarneeDear/83fc7e142063ae3e631f612856261611 to your computer and use it in GitHub Desktop.
//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