You can perform a login from Apex by using the SOAP API login method to retrieve the Session Id. You will need to add a Remote Site setting in your org and possibly append the users security token to the end of the password for this to work.
public with sharing class Login {
private static final String NS_SOAP = 'http://schemas.xmlsoap.org/soap/envelope/';
private static final String NS_SF = 'urn:partner.soap.sforce.com';
public static String login(String user, String password)
{
// As per http://wiki.developerforce.com/page/Enterprise_Login
HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setTimeout(60000);
req.setEndpoint('https://www.salesforce.com/services/Soap/u/29.0');
req.setHeader('Content-Type', 'text/xml;charset=UTF-8');
req.setHeader('SOAPAction', '""');
req.setBody('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header/><Body><login xmlns="urn:partner.soap.sforce.com"><username>' +user+ '</username><password>' + password + '</password></login></Body></Envelope>');
HttpResponse res = new Http().send(req);
if(res.getStatusCode() != 200)
{
Dom.Document responseDocument = res.getBodyDocument();
Dom.Xmlnode rootElm = responseDocument.getRootElement(); // soapenv:Envelope
Dom.Xmlnode bodyElm = rootElm.getChildElement('Body', NS_SOAP); // soapenv:Body
Dom.Xmlnode faultElm = bodyElm.getChildElement('Fault', NS_SOAP); // soapenv:Fault
Dom.Xmlnode faultStringElm = faultElm.getChildElement('faultstring', null); // faultstring
throw new LoginException(faultStringElm.getText());
}
// As per http://wiki.developerforce.com/page/Enterprise_Login
Dom.Document responseDocument = res.getBodyDocument();
Dom.Xmlnode rootElm = responseDocument.getRootElement(); // soapenv:Envelope
Dom.Xmlnode bodyElm = rootElm.getChildElement('Body', NS_SOAP); // soapenv:Body
Dom.Xmlnode loginResponseElm = bodyElm.getChildElement('loginResponse', NS_SF); // loginResponse
Dom.Xmlnode resultElm = loginResponseElm.getChildElement('result', NS_SF); // result
Dom.Xmlnode sessionIdElm = resultElm.getChildElement('sessionId', NS_SF); // sessionId
return sessionIdElm.getText();
}
public class LoginException extends Exception {}
}
Note on Security: It is of course not good to hard code your user name and password, ideally read it from some object and/or fields only visible to the user running the job (or if its enabled an Encrypted Field). Your other option might be to manually schedule the job via the developer console in this case passing in the user and password to the Scheduled class via its constructor (though i've not tested this as yet).