代码之家  ›  专栏  ›  技术社区  ›  Gus

Silverlight RIA服务-如何进行Windows身份验证?

  •  5
  • Gus  · 技术社区  · 17 年前


    它将部署在受控的公司内部网中,100%windows客户端。我从Silverlight业务应用程序模板开始。
    以下是我的要求:

    1. 启动时,应用程序需要识别当前登录的用户。
    2. 应用程序需要能够访问广告中用户的其他属性,例如电子邮件、全名和组成员资格。
    3. 组成员资格用于提升应用程序中的某些功能。


    我已在默认业务应用程序模板中修改了以下内容:

    1. App.xaml:appsvc:WindowsAuthentication而不是默认的FormsAuthentication

    通过这些修改,我解决了需求#1(获取当前登录的用户)。但是当我检查的时候 RiaContext.Current.User

    3 回复  |  直到 11 年前
        1
  •  4
  •   Michal    17 年前

    为此,您必须编写自己的配置文件提供程序,然后修改用户类以包含这些配置文件属性,然后才能访问这些属性。

    查看RIA服务概述文档的第13.3页,如果您需要帮助,请告诉我。

        2
  •  3
  •   Eric    16 年前

    大家好,MSDN上有一篇新文章,我正在看。

    http://msdn.microsoft.com/en-us/library/ee707353(VS.91).aspx

        3
  •  3
  •   CoolBeans Jake    15 年前

    下面是我如何在BusinessApplicationTemplate提供的AuthenticationService上对其进行黑客攻击的。

     [EnableClientAccess]
        public class AuthenticationService : AuthenticationBase<User> {
    
        protected override User  GetAuthenticatedUser(System.Security.Principal.IPrincipal principal)
        {
            User user = base.GetAuthenticatedUser(principal);
            Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
            SystemWebSectionGroup grp = (SystemWebSectionGroup)config.GetSectionGroup("system.web");
            AuthenticationSection auth = grp.Authentication;
            if (auth.Mode == AuthenticationMode.Forms)
            {
            }
            else if (auth.Mode == AuthenticationMode.Windows)
            {
                string[] a = user.Name.Split('\\');
                System.DirectoryServices.DirectoryEntry ADEntry = new System.DirectoryServices.DirectoryEntry("WinNT://" + a[0] + "/" + a[1]);
                string Name = ADEntry.Properties["FullName"].Value.ToString();
                user.Name = Name;
            }
            return user;
        }
    }