1

I'm using below code to authenticate my external user in SharePoint 2013 and this method not returning any claims token.So i am unable to authenticate user with SharePoint.However the same user i can authenticate through SharePoint portal.Through code i could't achieve.

SecurityToken token SPSecurityContext.SecurityTokenForFormsAuthentication("URL","MemberShip","Roleprovider","username","Password").

Is there any way to authenticate my external user through SharePoint server object model?

2 Answers 2

0

What do you want to do with authenticated user? You can create new SPSite object with needed user token and do what you want from that user.

Here is the link: http://www.sharepointdeveloperhq.com/2009/04/how-to-programmatically-impersonate-users-in-sharepoint/ You need switchUser method. You can get user's token this way: web.AllUsers[userLogin].UserToken.

0
bool status = SPClaimsUtility.AuthenticateFormsUser(Context.Request.UrlReferrer, "userid", "Password");

            if (!status)

            {

                Label1.Text = "Wrong Userid or Password";

            }

            else

            {

                if (Context.Request.QueryString.Keys.Count > 1)

                {

                    Response.Redirect(Context.Request.QueryString["Source"].ToString());

                }

                else

                    Response.Redirect(Context.Request.QueryString["ReturnUrl"].ToString());

            }

Ref : https://blogs.msdn.microsoft.com/pranab/2010/07/26/how-to-create-custom-login-page-for-sharepoint-2010-form-based-authentication-fba/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.