如何使用Windows身份验证在WPF中实现客户端应用程序服务? [英] How to implement Client Application Service in WPF with Windows Authentication?

查看:169
本文介绍了如何使用Windows身份验证在WPF中实现客户端应用程序服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用aspnet成员资格数据库配置了一个lightswitch应用程序。我用它来添加用户和角色。现在,我希望我的WPF使用具有Windows身份验证的客户端应用程序服务设置为特定的applicationName(在LightSwitch中使用相同)



在项目属性中配置项目后(服务)使用客户端应用程序服务,我在app.config会员提供程序中添加了applicationName。



然后在我的代码中,我尝试了以下内容:

I configured a lightswitch application with an aspnet membership database. I use it to add users and roles. Now, I want my WPF to use Client Application Services with Windows Authentication set up to an specific applicationName (Same used in LightSwitch)

After configuring my project in the project properties (Services) to use Client Application Service, I added to the app.config Membership Provider the applicationName.

Then in my code, I tried the following:

if (Membership.ValidateUser(null, null))
{
    if (Thread.CurrentPrincipal.IsInRole("TestRole"))
    {
        MessageBox.Show("User is in TestRole Role");
    } 
}





执行IsInRole方法时,我收到以下异常:无效的对象名称' UserProperties'



如何在WPF和aspnet会员数据库中使用Windows身份验证验证用户角色的任何想法或示例?



谢谢



When the IsInRole method is executed, I get the following exception: Invalid object name 'UserProperties'

Any idea or sample in how to verify user roles using windows authentication in WPF and aspnet membership database?

Thanks

推荐答案

我的方案解决了问题。



我最终使用了代码正如我原先提到的那样。但为了使其工作,我需要创建一组表格,如http://msdn.microsoft.com/en-us/library/bb384312.aspx中所述。



然后我使用这组表来存储用户/角色信息,而不是使用aspnet成员资格数据库。



添加这些表删除了错误异常无效的对象名称'UserProperties',因为'UserProperties'是其中一个表的名称。
Problem solved for my scenario.

I ended up using the code exactly as I mentioned originally. But in order to make it work, I needed to create a group of tables as mentioned in http://msdn.microsoft.com/en-us/library/bb384312.aspx.

Then instead of using the aspnet membership database, I use this set of tables to store User/Role information.

Adding those tables removed the error exception of "Invalid object name 'UserProperties'", since 'UserProperties' is the name of one of the tables created.


这篇关于如何使用Windows身份验证在WPF中实现客户端应用程序服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆