cancel
Showing results for 
Search instead for 
Did you mean: 

.Net VB Populate DropDownList with All Roles

Former Member
0 Kudos

I would like to populate a drop down box with the roles from the UserManagement. I am using the PDK for .Net 2.5 with EP 6.0 SP19. Could someone help me get started?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Thanks for the input. I am very familiar with the reference material but was looking for a little more help. Here is what I have. I get an error that says "Could not find a role with the unique name NA". I am trying to get all the roles with 'NA' in their name. Any help would be appreciated.

Public Sub FillDropDownList()

Dim ddli As New DropDownListItem

ddli.Text = "Please select a role"

ddli.Key = "0"

ddkRolesList.Items.Add(ddli)

Dim objUserManagement As New UserManagement()

Dim portalroles As Array

portalroles = objUserManagement.SearchRoles("NA", 1, False, 0)

Dim role As String

For Each role In portalroles

Dim rInfo As RoleInfo = objUserManagement.GetRoleByUniqueName(role)

Dim rName As String = rInfo.DisplayName

ddli = New DropDownListItem

ddli.Text = rName

ddli.Key = role

ddkRolesList.Items.Add(ddli)

Next role

End Sub

Former Member
0 Kudos

Hi Gabe,

how are you doing ?

the search mechanism exposed by the API is similar to what would happen when you execute it from User Administration within portal, see if you get the same error message from the Admin UI, most likely it should be the same. [remember to log on as the same user, as all reads are dependant on the priviliges associated to the current user's roles, groups, etc ...]

it will search for a role with the exact name 'NA' [this is case sensitive]

what you could try is expand the query to : "NA", or something similar to what is accurate to your requirement

also ensure that the current user [executing the query] has read permissions on the directory that your role is stored in [within the PCD]

with respect,

amit

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Gabe,

thank you for the 'solved problem' reward points

with respect,

amit

Former Member
0 Kudos

Hi Gabe,

Currently 2 portal services are exposed in the .NET PDK,

User Management is one of them

Add a reference to u're project to : SAP.Portal.Services.UserManagement.dll

RoleInfo is the class you need

the link will give you info on the Class : Role Info

https://media.sdn.sap.com/html/submitted_docs/dotnet/Reference/SAP.Portal.Services.UserManagement.Ro...

with respect,

amit

Former Member
0 Kudos

Hi Gabe

Please check this link.

<a href="https://media.sdn.sap.com/html/submitted_docs/dotnet/How%20to/User.IsInRole%20Method.htm">User Role Checking</a>

Regards

Geogi