Hi
I have an intermittent problem that I have not been able to resolve. I create users dynamically and assign roles to them as appropriate. This is achieved via a call from a remote service. Once created, users are redirected to the site and logged in automatically. As part of the log in process, I determine which specific role a user is in, and direct them to a tab appropriate to that role. Mostly this works fine, there are only a handful of roles of interest, and all have tested correctly.
However, every now and then, I get through the initial user creation process, and I can see that the user profile has been correctly created with the appropriate role assignment (via the admin user management control) however, I the role of interest to me does not appear in the objUser.IsInRole("") call.
My (truncated) code looks like the following
objUser.Roles = rc.GetRolesByUser(objUser.UserID, PortalId)
If (Not (objUser.Roles Is Nothing)) Then
If objUser.IsInRole("xx") Then
tabName = "xx"
ElseIf objUser.IsInRole("yy") Then
tabName = "yy"
'etc ...
End If
Dim homeTab As DotNetNuke.Entities.Tabs.TabInfo = x.GetTabByName(tabName, PortalId)
If Not (homeTab Is Nothing) Then
Return "default.aspx?TabId=" + homeTab.TabID.ToString()
Else
_logger.Log(LogLevel.Debug, "Couldnt find tab name {0} !!", tabName)
Return String.Empty
End If
I know all the roles exist in the system, and I can see wherever this fails that my user has been created correctly and been assigned to a role, so why does this code mostly work correctly, but occasionally fail?
Any assistance greatfully received..
Stuart