Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a custom usercontrol to logon users.

My Authentication setting:

  • Authentication Type: Windows

  • Enabled anonymous access

  • IIS Authentication Setting: Basic authentication

Now is the question how I can logon an anonymous user when he type a username + password and click login in the custom user control?

My current code in a IHttpModul:

IntPtr token = IntPtr.Zero;

                            bool result = User.LogonUser(userName,
                                                    host,
                                                    userPassword,
                                                    User.LogonSessionType.NetworkCleartext,
                                                    User.LogonProvider.Default,
                                                    out token);

                            if (result)
                            {
                                WindowsIdentity identity = new WindowsIdentity(token, "Basic");
                                WindowsPrincipal principal = new WindowsPrincipal(identity);

                                HttpContext.Current.User = principal;
                            }

But I get a login windows from internet explorer.

But the strang thing is when I click on the cancel button I am loged in into SharePoint!

Any suggestions?

share|improve this question
    
Why would you put this code in a Module? It'd run for every request that way... –  James Love Jan 22 '13 at 22:06
    
no.. I have some checks OF COURSE! :) before this code runs :) –  gicio Jan 23 '13 at 1:23
    
Have you tried moving this code into the codebehind of the user control? I'm betting your module runs after the SPRequestModule which handles the user identity... –  James Love Jan 23 '13 at 8:10
    
Yes I have. But with no reaction. –  gicio Jan 23 '13 at 13:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.