Search code examples
c#visual-studio-lightswitchlightswitch-2013

Getting registered users in LightSwitch


Background

I have a LightSwitch application that needs to implement a lightweight task management system. Something where a Manager could come in and create a task and then assign it to someone else. While I can do the query to find tasks created by the logged in user (see this blog on MSDN) it doesn't fully answer my question.

Question

How can I get the current list of registered users (the ones that the SysAdmin adds using the Form Auth selection and adds them in the Administration screen) in a drop down list and then 'assign' tasks to them?


Solution

  • You can use Membership.GetAllUsers() in your server project. You'll need to reference System.Web.Security to get access to it. This article talks about doing it in a WCF RIA Service but Generic File Handlers also work.

    Alternatively, if you want to filter the list of users by what permissions they have, you can use a LINQ query on this.DataWorkspace.SecurityData.Permissions. This forum post goes into a little more detail on constructing a possible query for specific users.