Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created a custom web part that let's the user sign in using their windows accounts. However, the I get Object Not Set to the Reference error when I set the SetPrincipalAndWriteSessionToken. Here is the code:

// Get Token
                var stoken = SPFormsUserNameSecurityTokenHandler.CreateSecurityToken(WindowsMembershipProvider, WindowsRoleProvider, username, password);
                if (stoken != null)
                {
                    // Sign User In
                    SPFederationAuthenticationModule fam = SPFederationAuthenticationModule.Current;   
                    fam.SetPrincipalAndWriteSessionToken(stoken);
                }

The WindowsMembershipProvider is "i", from the Web.Config and WindowsRoleProvider is "c" from the web.config. If I remove the roleprovider, it says "Value cannot be null", even though it is not a required parameter.

Can someone please help me out?

Thanks!

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

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.