SPUserToken userToken = SPContext.Current.Web.AllUsers["domain name\\UserLoginId"].UserToken;
using (SPSite site = new SPSite(SPContext.Current.Site.ID, userToken))
{
SPWeb myweb = site.OpenWeb();
Guid docsid=new Guid(hiddenDocumentLibraryName.Value);
SPDocumentLibrary myDocLib = (SPDocumentLibrary)myweb.Lists[docsid];
SPListItem items= myDocLib.Items.GetItemById(Convert.ToInt32(hiddenDocumentId.Value));
myweb.AllowUnsafeUpdates = true;
items.File.CheckOut();
}
using (SPSite site = new SPSite(SPContext.Current.Site.ID, userToken))
{
SPWeb myweb = site.OpenWeb();
Guid docsid=new Guid(hiddenDocumentLibraryName.Value);
SPDocumentLibrary myDocLib = (SPDocumentLibrary)myweb.Lists[docsid];
SPListItem items= myDocLib.Items.GetItemById(Convert.ToInt32(hiddenDocumentId.Value));
myweb.AllowUnsafeUpdates = true;
items.File.CheckOut();
}