Monday, February 23, 2015

Programatically increase security validation timeout for a web application in Sharepoint

Environment: SharePoint Server 2013

Requirement: Programatically increase security validation timeout for a web application in SharePoint

Solution: The following line of code will set the Web Page Security Validation expiry to 60 minutes

   SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://webappURL/"));

   //Use TimeSpan constructor to specify Days, hours, minutes, seconds
    webApp.FormDigestSettings.Timeout = new TimeSpan(1, 0, 0); 

  //Save the changes 
    webApp.Update();

NoteYou'll get access denied error when the above code is executed within RWEP as it runs the code under the Application Pool account of the your web application. You need to run this code with farm account as the SPWebApplication is stored in config database. Use SPUserToken and farm account to run this code.

Wednesday, February 4, 2015

OpenSSL - No such file or directory

Scenario: Trying to convert csr certificate to crt using OpenSSL and getting following error
Command used: OpenSSL> x509 -req -in server.csr -signkey server.key -out server.crt

Issue: 
Loading 'screen' into random state - done
server.csr: No such file or directory
error in x509

Resolution:
Provide full path for both .csr and .key file to run this command successfully.