Forum Discussion

bhanu chintha's avatar
bhanu chintha
Iron Contributor
Sep 19, 2017
Solved

PnP Timer Job - OnPremise Connectivity - Run Method Call

Hello,

 

I have written a TimerJob based on PnP Framework and tried to connect to the SP 2013 On-Premise site. 

 

https://msdn.microsoft.com/en-us/pnp_articles/timerjob-framework

 

I have used the below authentication and the issue i am getting is - TimerJob Run method is not getting executed and i do not see exception/error here.

 

public void UseNetworkCredentialsAuthentication(string samAccountName, string password, string domain)

 

The same job is working fine if i tried to connect to SP Online and use the below authentication -

 

public void UseOffice365Authentication(string userUPN, string password)

 

Did someone face this kind of issue. Please let me know.

 

 

Thanks & Regards,

Bhanu

  • As far as I remember, you have to take care about PnP version to be used since there is a separation between PnP for SPO and PnP for SP OnPrem

3 Replies

  • As far as I remember, you have to take care about PnP version to be used since there is a separation between PnP for SPO and PnP for SP OnPrem
    • bhanu chintha's avatar
      bhanu chintha
      Iron Contributor

      I tried with SP 2013 nugget package and it worked fine.

       

      But, I still doubt why the latest package do not work with SP 2013 when it has provided methods to connect to On-Premise environment. Is this a bug?

       

      Thanks & Regards,

      Bhanu

       

    • bhanu chintha's avatar
      bhanu chintha
      Iron Contributor

      Hello Juan,

       

      Thanks for your reply.

       

      I am using the OfficeDevPnP.Core.Framework.TimerJobs api here. So, I think this should be intelligent enough to handle connections to SP Online/OnPremise.  

       

      Here is the code that i have written - 

       

      class Program
      {
      static void Main(string[] args)
      {
      Class1 job = new Class1();
      job.AddSite("https://OnPremSiteURL");
      job.UseNetworkCredentialsAuthentication("username", "password", "domain");
      job.Run();
      }
      }

       

      class Class1 : TimerJob
      {
      public Class1() : base("CustomListArchivalJob")
      {
      TimerJobRun += Class1_TimerJobRun;
      ManageState = true;
      }

      private void Class1_TimerJobRun(object sender, TimerJobRunEventArgs e)
      {
      }
      }

       

      Thanks & Regards,

      Bhanu