+ Start a Discussion
sunil_kumarsunil_kumar 

Embedding Partner Portal login page in visualforce Page

Hi all,

 

I want to embed partner portal login page into my visualforce page.

Can anyone please let me know how to do this?

Best Answer chosen by Admin (Salesforce Developers) 
RyanGuestRyanGuest

Change the login method to this:

 

return site.login(username, password, '/home/home.jsp');

 

Does that work?

All Answers

SurekaSureka

Hi,

 

Create a VF page, with the same look and feel as  Partner portal login page.

 

Embed this VF page in your VF page.

 

When the users login, you need to pass the Organisation id , partner portal Id, User Id of partner portal user, Corresponding Contact id and the user name.

 

Substitue the values in the url and re-direct - /servlet/servlet.su?oid=valoid&suportaluserid=userid&retURL=/conid&targetURL=/home/home.jsp&suportalid=custportalid

 

where valoid - corresponding organization

 

            Userid -customer portal user

 

            conid  - corresponding contact Id

 

            custportalid - Id of the corresponding customer portal where you need to login.

 

Hope this helps.

 

Thanks

Madhura BMadhura B

Hi Sureka,

 

I followed the method which you suggested; but when I login as a user from the VF page I get the following error message:

System.NullPointerException: Argument cannot be null. 

 

I also tried accessing the VF page by making it a site and when I login there the page I get after hitting submit is down for maintenance.

 

Can you please tell me what can be done.  

 

Thank you

sunil_kumarsunil_kumar

Hi Sureka,

 

I had created a vf page with same look and feel of partner portal login page. When user login i am passing orgId,portalId,userId,contactId in the url and try to login by using site.login method on partner portal.

the controller login method is:

 

public PageReference login()   
  { 
  
  String startUrl = System.currentPageReference().getParameters().get('ap1.salesforce.com/secur/login_portal.jsp?orgId=00D90000000IExn&portalId=06090000000PeC9&retURL=/00390000001qmLH&targetURL=/home/home.jsp&suportaluserid=00590000000d0Qz');    
  return site.login(username, password, startUrl);
}

 

I am able to login on partner portal but after loging i am getting same vf login page on partner portal home page. After that if i go to other tabs like cases etc then its shows standard partner portal pages.

 

I want that username and password field on vf login page don't appear on partner portal home page.

 

Can you suggest how to do this or tell some alternate way to login on partner portal page from visualforce page?

RyanGuestRyanGuest

I'm a little confused about what you are doing here.

 

Are you trying to create a public site that has a login to your Partner Portal? If so, when you create a new site, you'll get a page in your organization called "SiteLogin". You can use that as an example of how to create a login page.

 

The Apex method Site.login() only works in the context of a site, otherwise it won't work.

sunil_kumarsunil_kumar

Hi Ryan,

 

When i am using site login page for login into partner portal then i am able to do that but after login i should get partner portal home page but i am getting site login page superimposed on partner portal home page. After login i get access to all tabs but username and password field is visible on partner portal home page. after that if i click some other tab then its behave normally and site login page disappear. I am not able to understand the reason for this.

 

Can you suggest something?

 

RyanGuestRyanGuest

Change the login method to this:

 

return site.login(username, password, '/home/home.jsp');

 

Does that work?

This was selected as the best answer
Madhura BMadhura B

Thank You Ryan,

It worked!

sunil_kumarsunil_kumar

Thanks Ryan,

 

problem was with url. Now its working..

B2000B2000

I have created a VF page for a site that is the login for portal users to goto the portal home page.  I tried using your suggestion  site.login (username,password,'/home/home.jsp').  The portal home page starts to load but immediately redirects to the standard salesforce login page with the following message:

 

"You have attempted to access a page that requires a salesforce.com login. If you are already a user of the system, please login below."

 

Here is the site VF Page and the controller.

Any ideas? 

Thanks

 

 

    <apex:form id="loginForm" forceSSL="true">

        <apex:panelGrid >
            <apex:image url="ALOGO.GIF" style="align: left;" alt="Salesforce"  title="Salesforce"/>
        </apex:panelGrid>
        
        <center>
        <div style="background-color:#B8CBC5;">
            <apex:panelGrid bgcolor="#656565" columns="1"> 
                <br/>
                <br/>
                <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="#B8CBC5" columns="1" styleClass="topPanelContainer"> 
                    <br/>
                    <apex:outputPanel layout="block" styleClass="topPanel">
                        <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="lightgray" columns="2"> 
                            <apex:image url="ANIMAGE.GIF"/>
                            <apex:panelGroup >
                                <br/>
                                <apex:outputText styleClass="title" value="{!$Label.site.login}"/>
                                <br/>
                
                                <apex:outputPanel layout="block">
                                    <apex:pageMessages id="error"/>
                                    <apex:panelGrid columns="2" style="margin-top:1em;">
                                        <apex:outputLabel value="{!$Label.site.username}" for="username"/>
                                        <apex:inputText id="username" value="{!username}"/>
                                        <apex:outputLabel value="{!$Label.site.password}" for="password"/>
                                        <apex:inputSecret id="password" value="{!password}"/>
                                        <apex:outputText value=""/>
                                        <apex:commandButton action="{!login}" value="{!$Label.site.login_button}" id="loginButton"/>
                                        <apex:outputText value=""/>
                                        <apex:outputText value=""/>
                                        <apex:outputText value=""/>
                                        <apex:panelGroup id="theLinks">
                                            <apex:outputLink value="{!$Page.ForgotPassword}"> {!$Label.site.forgot_your_password_q}</apex:outputLink>
                                            <apex:outputText value=" | " rendered="{!$Site.RegistrationEnabled}" />
                                            <apex:outputLink value="{!$Page.SiteRegister}" rendered="{!$Site.RegistrationEnabled}">{!$Label.site.new_user_q}</apex:outputLink>
                                        </apex:panelGroup>
                                    </apex:panelGrid> 
                                </apex:outputPanel>
                                
                                <br/>
                            </apex:panelGroup>
                        </apex:panelGrid> 
                    </apex:outputPanel>

                    <c:ACOMPONENT displays a logo/> 

                </apex:panelGrid> 
            </apex:panelGrid>
            <br/>
        </div>
        </center>

    </apex:form>

 

 

 

global class TestLogin 
{
	Global String username {get;set;}
	Global String password {get;set;}
	
	Global TestLogin(){}
	
	Global pageReference login()
	{
          return site.Login(username,password,'/home/home.jsp');
		
	}
}

 

 

B2000B2000

I realize now that the site.login is only for the site.  I modified the code to login to the portal as follows and it works correctly:

 

 

	Global pageReference login()
	{
		
		String startURL = 'https://na6.salesforce.com/secur/login_portal.jsp';
		startURL += '?orgId=00Dxxxxxxxxxxxx&portalId=060yyyyyyyyyyyy&loginType=3';
		startURL += '&startURL=&loginURL=&useSecure=true';
		startURL += '&un=' + username;
		startURL += '&pw='+ password;
		
 		pageReference p = new PageReference(startURL);
 		p.setredirect(true);
 		return p;
	}