檢查這個blog通過Steve Peschka。我使用該博客在受SiteMinder保護的SharePoint 2013中設置了提供商託管的應用程序。爲了模擬用戶,您需要創建用戶的ClaimsIdentity並將其作爲當前用戶插入到HttpContext中。下面的示例代碼:
var identity = new ClaimsIdentity(AuthenticationTypes.Federation, "http://schemas.xmlsoap.org/claims/useridentifier", String.Empty);
identity.AddClaim(new Claim("http://schemas.xmlsoap.org/claims/useridentifier", userId, "http://www.w3.org/2001/XMLSchema#string"));
identity.AddClaim(new Claim(ClaimTypes.Email, smtp, "http://www.w3.org/2001/XMLSchema#string"));
identity.AddClaim(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/sip", nameIdentifier, "http://www.w3.org/2001/XMLSchema#string"));
ClaimsPrincipal principal = new ClaimsPrincipal(identity);
設置此聲明爲Principalas Httpcontext用戶。 要傳遞的聲明值是smtp =用戶的電子郵件地址,nameidentifier =用戶的登錄名,userId =用戶的帳戶名稱
謝謝我會試一試.Steve的博客非常豐富,但它沒有附件了。你有沒有附件? – user669915