Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Using DNN User Authentication from external webappUsing DNN User Authentication from external webapp
Previous
 
Next
New Post
12/2/2006 9:21 AM
 

Hi,

I'm trying to create a very simple web application that uses DNN user authentication. It means that a registered user of my DNN portal, should be able to log in to my web application using his/her portal userid and passw.  So my web-app needs to ask somehow DNN if the userid and passw given by the user is correct or not. Here is what I have done so far:

1. Checked Signin.ascx.vb to see what's happening there, when clicking the login button of a DNN Portal (see code attached to the end of this message)  

2. Created a C# website (application) project in VS2005

3. Added a reference to my project for dotnetnuke.dll

4. Added the code below to my Page_Load function

5. Running the application I got exceptions like:

      The type initializer for 'DotNetNuke.Entities.Users.UserController' threw an exception.     

       The type initializer for 'DotNetNuke.Services.Cache.CachingProvider' threw an exception.

I'm quite sure I missed a few steps. I have never done anything similar before, and totally no idea what to do, please take a look at the codes below, I would really  appreciate any guidlines to this!

Thanks!

Örs Téglásy


C# code from my demo webapp, trying to ask DNN to check userid and passw:

using DotNetNuke;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = "before try";
        try
        {
            DotNetNuke.Entities.Users.UserInfo dnnUserInfo = new DotNetNuke.Entities.Users.UserInfo();
            DotNetNuke.Security.Membership.UserLoginStatus dnnUserLoginStatus = new DotNetNuke.Security.Membership.UserLoginStatus();
            String ipAddress = Request.UserHostAddress;

            //String veriCode = Request.QueryString["verificationcode"];
            String portalName = DotNetNuke.Entities.Portals.PortalSettings.GetPortalByID(0, "");
                    
            dnnUserInfo = DotNetNuke.Entities.Users.UserController.ValidateUser(0, "johnsmith", "abc1234", "", portalName , ipAddress, ref dnnUserLoginStatus);
            Label1.Text = dnnUserInfo.DisplayName;
        }
        catch (TypeInitializationException ex)
        {
            Label1.Text = "in catch: " + ex.Message;

        }
    }
}


 This is the code from Signin.ascx.vb, to see what's happening there when you click the login button:

Private Sub cmdLogin_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdLogin.Click

            If (UseCaptcha And ctlCaptcha.IsValid) OrElse (Not UseCaptcha) Then
                'Try to validate user
                Dim loginStatus As UserLoginStatus
                Dim objUser As UserInfo = UserController.ValidateUser(PortalId, txtUsername.Text, txtPassword.Text, txtVerification.Text, PortalSettings.PortalName, ipAddress, loginStatus)

                If objUser Is Nothing Then  'Some kind of Login failure
                    If loginStatus = UserLoginStatus.LOGIN_FAILURE Then
                        'Try Windows Authorization
                        '(user may be authorized in Windows, but not in DNN yet)
                        objUser = WindowsAuthorization(loginStatus)
                    End If
                End If

                If objUser Is Nothing Then
                    Select Case loginStatus
                        Case UserLoginStatus.LOGIN_USERNOTAPPROVED
                            'Check if its the first time logging in to a verified site
                            If PortalSettings.UserRegistration = PortalRegistrationType.VerifiedRegistration Then
                                If Not rowVerification1.Visible Then
                                    'Display Verification Rows so User can enter verification code
                                    rowVerification1.Visible = True
                                    rowVerification2.Visible = True
                                Else
                                    If txtVerification.Text <> "" Then
                                        AddModuleMessage("InvalidCode", ModuleMessageType.RedError, True)
                                    Else
                                        AddModuleMessage("EnterCode", ModuleMessageType.GreenSuccess, True)
                                    End If
                                End If
                            End If
                        Case UserLoginStatus.LOGIN_USERLOCKEDOUT
                            AddModuleMessage("UserLockedOut", ModuleMessageType.RedError, True)
                            ' notify administrator about account lockout ( possible hack attempt )
                            Dim Custom As New ArrayList
                            Custom.Add(txtUsername.Text)
                            Mail.SendMail(PortalSettings.Email, PortalSettings.Email, "", _
                                Localization.GetSystemMessage(PortalSettings, "EMAIL_USER_LOCKOUT_SUBJECT", Localization.GlobalResourceFile, Custom), _
                                Localization.GetSystemMessage(PortalSettings, "EMAIL_USER_LOCKOUT_BODY", Localization.GlobalResourceFile, Custom), _
                                "", "", "", "", "", "")
                        Case UserLoginStatus.LOGIN_FAILURE
                            AddModuleMessage("LoginFailed", ModuleMessageType.RedError, True)
                    End Select
                Else    'Login Success
                    UserAuthorized(objUser, False)
                End If
            End If

        End Sub

 
New Post
12/3/2006 10:14 PM
 
While I don't have the answer myself, you might be interested in this thread.

    - Doug Vogel     

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Using DNN User Authentication from external webappUsing DNN User Authentication from external webapp


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out