0

We can get the roles of an SPUser by SPUser.Roles. But it will return SPRoleCollection. If we want to list all the roles we need to loop that.

For example an User has "Full Control","Read","Design" we need to loop the SPRoleCollection object.

How can i get all the roles as a string with ',' separator?

Brian Mains
  • 50,520
  • 35
  • 148
  • 257
john
  • 121
  • 1
  • 3
  • 17

1 Answers1

2

As a rough guess, try:

var user = SPUser // However you get the user.

var roles = Sring.Join(",", (from r in user.Roles select r.Name).ToArray()));

Though if you're using SharePoint 2010, the Name property is obsolete apparently.

Jason Evans
  • 28,906
  • 14
  • 90
  • 154