2010-04-20 62 views

回答

3

此博客文章有答案。 Silverlight with WCF Ria Services and Active Directory Roles。感謝丹這篇文章!

我正在使用Silverlight 4,所以自從這篇文章發生了一些改變。我還爲這個項目使用了業務應用程序模板。

第1步。這已經在App.xaml.cs代碼後面的BussinessApplication模板中設置。您需要註釋webContext.Authentication = new FormsAuthentication();,並取消註釋行webContext.Authentication = new WindowsAuthentication();

第2步。沒有變化。將<authentication mode="Windows"/>添加到/configuration/system.web元素下的web.config。

第3步。RiaContex現在是WebContext,因此請在示例中更改此內容。加載用戶的第一行,RiaContext.Current.Authentication.LoadUser(this.Application_UserLoaded, null);已經在代碼中。

第4步。沒有變化。將<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider"/>添加到/configuration/system.web元素下的web.config。

通過這些小的更改,Silverlight應用程序連接到Active Directory並填充了我正在尋找的WebContext.Current.User.Roles