kiquenet / dropthings

Automatically exported from code.google.com/p/dropthings
0 stars 0 forks source link

Encounter error after apply Windows authentication #83

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Download Dropthings-2.5.5-src and open the solution with Visual Studio 
2008.
2. Changed the "Authentication" mode in web.config file to <authentication 
mode="Windows"></authentication>.
3. Run the project, I got an error in Facade.User.cs (under 
Dropthings.Business.Facade). 
The error occured in function: GetUserSetting(Guid userGuid)
The line that return error: newSetting.CurrentPageId = 
this.pageRepository.GetPageIdByUserGuid(userGuid).First();
Error message: Sequence contains no elements.

What version of the product are you using? On what operating system?
Dropthings-2.5.5-src
Windows XP SP3
Visual Studio 2008
SQL Server 2008

Original issue reported on code.google.com by albert...@gmail.com on 5 May 2010 at 8:45

GoogleCodeExporter commented 8 years ago
Windows authentication is not supported as it is. You will have to tweak the 
login page to validate the username and password against Windows and then use 
Membership.CreateUser to create a user account using the username. After that 
call this:

UserSetup FirstVisitHomeTab(string userName, string pageTitle, bool 
isAnonymous, bool isFirstVisitAfterLogin)

isFirstVisitAfterLogin = true

Original comment by omaralzabir@gmail.com on 11 Jun 2010 at 8:58

GoogleCodeExporter commented 8 years ago
Thanks for the reply. I have now moved to Dropthings-2.6.2.

I coded the below in Default.aspx's Page_Load function:

if (!Membership.ValidateUser(Profile.UserName, "Password"))
        {
            bool activationRequired = ConstantHelper.ActivationRequired;

            RegisterUserResponse registerUserResponse = null;
            using (var facade = new Facade(AppContext.GetContext(Context)))
            {
                registerUserResponse = facade.RegisterUser(Profile.UserName, "Password", Profile.UserName, activationRequired);
            }
        }

My question is: where should I add the below that you mentioned in your reply?

UserSetup FirstVisitHomeTab(string userName, string pageTitle, bool 
isAnonymous, bool isFirstVisitAfterLogin)

isFirstVisitAfterLogin = true

Original comment by albert...@gmail.com on 11 Jun 2010 at 9:16

GoogleCodeExporter commented 8 years ago
You need to call the FirstVisitHomeTab right before calling RegisterUser using 
the Profile.UserName and pass isFirstVisitAfterLogin as true.

Original comment by omaralzabir@gmail.com on 16 Jun 2010 at 12:50

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I believe you mean FirstVisitHomePage not "FirstVisitHomeTab". 

_Setup = facade.FirstVisitHomePage(Profile.UserName, pageTitle, false, true);

Original comment by romm...@gmail.com on 16 Jun 2010 at 11:14

GoogleCodeExporter commented 8 years ago
It should be tab. I changed "Page" to "Tab" in latest version to avoid 
confusion.

Original comment by omaralzabir@gmail.com on 17 Jun 2010 at 8:46

GoogleCodeExporter commented 8 years ago
albertlse, did you have to do any more customization to get Dropthings-2.6.2 to 
work with active directory / Windows authentication? If you could share / 
publish your solution it would be very helpful. I tried just the steps here and 
have not yet tweaked the login page.

Original comment by romm...@gmail.com on 18 Jun 2010 at 2:40

GoogleCodeExporter commented 8 years ago
rommelb, I am using Dropthings-2.6.4 now as 2.6.2 is no longer available.

I customized it to work with Windows Authentication.

My default.aspx Page_Load function looks like this:

protected void Page_Load(object sender, EventArgs e)
    {
        if (!Membership.ValidateUser(Profile.UserName, "Password"))
        {
            bool activationRequired = ConstantHelper.ActivationRequired;

            RegisterUserResponse registerUserResponse = null;
            var facade = Services.Get<Facade>();
            {
                registerUserResponse = facade.RegisterUser(Profile.UserName, "Password", Profile.UserName, activationRequired);
            }
        }
    }

Also, I add <authentication mode="Windows"></authentication> to web.config.

It auto-register the user on the first load of the homepage. 

However, I encountered a problem in 2.6.4. I have reported this problem in 
Issue #118 (http://code.google.com/p/dropthings/issues/detail?id=118)

Till now there's no response to the issue I have reported.

rommelb, do you mind to check is you encounter the same in Issue #118?

Hope omaralzabir or anyone can help to resolve Issue #118.

Thank you.

Original comment by albert...@gmail.com on 18 Jun 2010 at 2:54

GoogleCodeExporter commented 8 years ago
albertlse - any more success in getting this to work with windows 
authentication?

I have made the changes you suggested above.  I added the Page_Load and also 
changed the web config as above (and removed the existing Forms authentication).

Do I need to do anything else?

I have the latest version which I think is 2.6.5....

Thanks for any help!

Original comment by steran...@gmail.com on 18 Nov 2010 at 4:55