Role-Based Security

The following code extracts from the database the list of application-defined roles associated with the logged-on user strUserName. The list is stored in the string array strRoles:

strRoles = RoleBasedSecurity.LoadRoles(strUserName)

The next line of code shown assigns the Principal for strUserName—containing the user name and associated roles—to the current thread:

RoleBasedSecurity.SetPrincipalPolicy strUserName

Get Security for Microsoft® Visual Basic® .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.