Hi I am integrating our existing web application so it can be implemented as modules in a DNN website. Part of this means having a double login which I have figured out how to do. I just create the DNN Users on the fly after the username/password has been validated by our application. This creation only happens the first time the person signs in. After that whenever they log in it checks the username pass on our member ablication and then progromatically logs you into DotNetNuke.
Now our application has permissions just like DNN so i duplicated the roles in dotnetnuke. After i create the DNN user for the first time I add the roles programattically using the Subroutine
Sub AddUserRole(PortalID, UserID, RoleID, ExpirationDate)
The only problem is when i do it it give me this error: Object reference not set to an instance of an object. However when I check the DNN UserRoles table the roles get added correctly so I'm not sure where the error would possibly be coming from.
The function code is below. Please help. Thank you.
Public Sub AddUserRole(ByVal PortalID As Integer, ByVal UserId As Integer, ByVal RoleId As Integer, ByVal ExpiryDate As Date)
Dim originalAppName As String = ""
Dim objUserController As New UserController
Dim objUser As UserInfo = objUserController.GetUser(PortalID, UserId)
Dim objUserRole As UserRoleInfo = GetUserRole(PortalID, UserId, RoleId)
If objUserRole Is Nothing Then
originalAppName = Common.Globals.GetApplicationName
Common.Globals.SetApplicationName(PortalID)
DataProvider.Instance().AddUserRole(PortalID, UserId, RoleId, ExpiryDate)
objUserRole = GetUserRole(PortalID, UserId, RoleId)
Try
AspNetSecurity.Roles.AddUserToRole(objUser.Membership.Username, objUserRole.RoleName)
Catch ex As Exception
'Reset the Application Name
Common.Globals.SetApplicationName(originalAppName) End Try
Else
DataProvider.Instance().UpdateUserRole(objUserRole.UserRoleID, ExpiryDate)
End If
End Sub
KC Abramson
www.ORCradio.comWeb Application Developer
Integrated Software Solutions, Inc.
When you're feeling down just remember.....the best things in life are someone else's.