function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfetfsfetf 

Authenticating self-service users

I need to authenticate self-service users, but don't want to use the self-service login page (I want to create a new page that accepts self-service username and password).

I don't want to create a user database to authenticate the self-service users as suggested in other posts, and I also don't want to use a single password solution as suggested in other posts.

From the documentation this may be done through LoginScopeHeader, but I can't find any code samples that do that.

Does anybody have a good sample that authenticates an existing self-service user?  (using LoginScopeHeader or not)

SuperfellSuperfell
it works just like regular login except you just need to create the loginscopeheader and set the organiationId property, e.g.

stub = new Sforce.SforceService();
stub.LoginSCopeHeaderValue = new sforce.LoginScopeHeader();
stub.LoginSCopeHeaderValue.organizationId = "00D......";// whatever your 18 char organizationId is
sforce.LoginResult lr = stub.login("selfserve@foo.org", "saas");


Cheers
Simon
Michael.WatkinsMichael.Watkins
        Public Function Login(ByVal SelfServiceUserID As String, ByVal SelfServicePassword As String, ByVal sOrganizationID As             String, ByVal APIUserID As String, ByVal APIUserPassword As String) As Boolean
           
            Dim oProxy As New SforceService
            Dim oLoginResult As New LoginResult()
            Dim LoggedInSelfServiceUserID As String = ""

            '   SelfServiceUser authentication
            Dim oSelfServiceUser As New SelfServiceUser
            Dim oLoginScopeHeader As LoginScopeHeader = New LoginScopeHeader()

            oLoginScopeHeader.organizationId = sOrganizationID
            oProxy.LoginScopeHeaderValue = oLoginScopeHeader

            Try
                oLoginResult = oProxy.login(SelfServiceUserID, SelfServicePassword)
                LoggedInSelfServiceUserID = oLoginResult.userId
                Return True


            Catch ex As Exception
                Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex)
                Return False
            End Try


            '   ******************************************************************************
            '   SelfServiceUser has been authenticated, but they have no access to the API
            '   Re-Login with regular user credentials to access the API

            oProxy = New sForce.SforceService

            Try
                oLoginResult = oProxy.login(APIUserID, APIUserPassword)

            Catch ex As Exception
                Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex)
                Return False

            End Try
End Function