This is how I do it. I have already setup a user in DNN, which is just my user for allowing me lo be logged in:
username: MyUserName
passwoed: MyPassword
#HACK:
Private Sub LoginDNN(u As String, p As String)
Dim loginStatus As UserLoginStatus = UserLoginStatus.LOGIN_FAILURE
Dim objUser As UserInfo = UserController.ValidateUser(PortalId, u, p, "DNN", PortalSettings.PortalName, ip, loginStatus) ' check for lead cookies and other items for history logging
If loginStatus = UserLoginStatus.LOGIN_SUCCESS Then
' success
UserController.UserLogin(Me.PortalId, objUser, PortalSettings.PortalName, Me.Request.UserHostAddress, False)
End If
End Sub
' call the Sub with pre-made credentials if they are authed externally
If AlreadyAuthed then
LoginDNN("MyUserName", "MyPassword")
End If