You need to sign in to do that
Don't have an account?
![sravan36 sravan36](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Customer Portal Single Sign On using Web Service call.
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SFDCApplication.sforce;
using System.Web.Services.Protocols;
{
public partial class _Default : System.Web.UI.Page
{
private SforceService newService;
protected void Page_Load(object sender, EventArgs e)
{
{
try
{
string userName = "*********@******";
string passWord = "**********";
string orgId = "**************";
string portId = "****************";
LoginScopeHeader header = new LoginScopeHeader();
header.organizationId = orgId;
header.portalId = portId;
newService.LoginScopeHeaderValue = header;
try
{
logRes = newService.login(userName, passWord);
}
catch (SoapException ex)
{
Console.WriteLine(ex.Code);
Console.WriteLine("An unexpected error has occurred: " + ex.Message);
Console.WriteLine(ex.StackTrace);
throw new Exception();
}
{
Console.WriteLine("An error has occurred. Your password has expired.");
throw new Exception();
}
newService.SessionHeaderValue = new SessionHeader();
newService.SessionHeaderValue.sessionId = logRes.sessionId;
{
string redirectURL = "https://<CompanyName>.testing.cs10.force.com/customerportal /apex/viewcases?sessionid=" + logRes.sessionId;
Response.Redirect(redirectURL);
}
}
catch (Exception ex)
{
lblErr.Text = ex.Message;
}
}
}
Also i am getting the same session id again and again instead of different session id's each and every time. Then i just changed my code a little bit.
Instead of redirecting i called the logout() method, which flushes the existing session and again i called the Login() method, which creates a new session id for me. Code change as below
if (logRes.sessionId != "" && logRes.sessionId != string.Empty)
{
this.newService.logout();
logRes = newService.login(userName, passWord);
string redirectURL = "https://<CompanyName>.testing.cs10.force.com/customerportal /apex/viewcases?sessionid=" + logRes.sessionId;
Response.Redirect(redirectURL);
}
- luckily it worked and i was getting a new session id each and every time.
After this also i am getting the same error as
Error: File Not Found.
Authorization Required
You must first log in or register before accessing this page.
If you have forgotten your password, click Forgot Password to reset it.
What is wrong in this, am i missing out anything in code. Any suggestions and ideas will be appreciated.
Thanks in advance.