우리는 Silverlight 5 프로젝트와 함께 WCF Ria Services를 사용하고 있습니다. 인증을 위해 RIA Services 클래스 라이브러리에서 맞춤 멤버쉽 공급자 WCF Ria Service를 사용하고 있습니다. 클라이언트 측 인증 실행 중 .WebContext.Current.User.Name.But 서버 측 ServiceContext.User 비어있는 현재 사용자 이름에 액세스합니다. [RequireAuthentication] attr을 사용하는 경우. DomainServices에서 항상 Access Denied를 반환합니다. 어떻게 WebContext.Current.user를 ServiceContext.user로 푸시 할 수 있습니까? 여러 문서 및 자습서를 읽었지만 모든 테스트가 실패합니다.WCF RIA 서비스 양식 인증 ServiceContext.User.Identity.Name 비어 있습니다.
코드 예제 :
있는 CustomMembershipProvider.cs :
public class CustomMembershipProvider : MembershipProvider {
public override bool ValidateUser(string username, string password)
{
using (var context = new TimEntities())
{
var user = context.User.FirstOrDefault(u => u.Username == username &&
u.Password == password);
return user != null;
}
}
}
AuthenticationDomainService :
[EnableClientAccess]
public class AuthenticationDomainService : AuthenticationBase<AuthUser>
{}
public class AuthUser : UserBase
{}
App.xaml.cs를 :
var webContext = new WebContext();
var formsAuth = new FormsAuthentication();
var authContext = new AuthenticationDomainContext();
formsAuth.DomainContext = authContext;
webContext.Authentication = formsAuth;
ApplicationLifetimeObjects.Add(webContext);