Can not get HTTP Header in COGNOS Custom Authentication provider - cognos

I am working on implementing COGNOS Custom Authentication provider (Java) with SSO (Oracle Access manager(OAM)).
The way OAM works is that it looks for a Valid Session Token Cookie in every HTTP/HTTPS request and when not found it redirects to the OAM log in page.
If the cookie is valid/authorized, it also a adds a HTTP HEADER and sets the user name in it and redirects to Cognos URL. Cognos now send this call to Custom Authentication Provider.
Now my problem is that I am not able to read this Header value inside Custom Authentication Provider.
I tried adding a ASP page and it can read the values this proves that values are being passed and their is some problem with the way I am doing this in CAP Java code.
Snippet from code I am trying to use.
Note: I can get the cookie fine but all the headers are always NULL.
Note2: I have tried using both INamespaceAuthenticationProvider/IBiBusHeader and INamespaceAuthenticationProvider2/IBiBusHeader2
public class CAPClass extends Namespace
implements INamespaceAuthenticationProvider
{
private String GetSingleValue(String[] value)
{
if(value != null && value.length > 0)
return value[0];
else
return null;
}
public void createLogs(String var, IBiBusHeader theAuthRequest)
{
CreateLog.LogMsg(var + ": " + GetSingleValue(theAuthRequest.getEnvVarValue(var)));
CreateLog.LogMsg(var + ": " + GetSingleValue(theAuthRequest.getTrustedEnvVarValue(var)));
CreateLog.LogMsg(var + ": " + GetSingleValue(theAuthRequest.getCredentialValue(var)));
//CreateLog.LogMsg(var + ": " + GetSingleValue(theAuthRequest.getTrustedCredentialValue(var)));
}
public IVisa logon(IBiBusHeader theAuthRequest)
throws UserRecoverableException, SystemRecoverableException,
UnrecoverableException
{
String var = "ObSSOCookie";
String SessTok = GetSingleValue(theAuthRequest.getCookieValue(var));
CreateLog.LogMsg(var + ": " + SessTok);
var = "REMOTE_USER";
createLogs(var, theAuthRequest);
var = "HTTP_REMOTE_USER";
createLogs(var, theAuthRequest);
var = "HEADER_REMOTE_USER";
createLogs(var, theAuthRequest);
var = "HEADER_HTTP_REMOTE_USER";
createLogs(var, theAuthRequest);
var = "HTTP_HEADER_REMOTE_USER";
createLogs(var, theAuthRequest);
var = "SSO_LOGIN_ID";
createLogs(var, theAuthRequest);
var = "HTTP_SSO_LOGIN_ID";
createLogs(var, theAuthRequest);
var = "HEADER_SSO_LOGIN_ID";
createLogs(var, theAuthRequest);
var = "HEADER_HTTP_SSO_LOGIN_ID";
createLogs(var, theAuthRequest);
var = "HTTP_HEADER_SSO_LOGIN_ID";
createLogs(var, theAuthRequest);
var = "OAM_REMOTE_USER";
createLogs(var, theAuthRequest);
var = "HTTP_OAM_REMOTE_USER";
createLogs(var, theAuthRequest);
var = "HEADER_OAM_REMOTE_USER";
createLogs(var, theAuthRequest);
var = "HEADER_HTTP_OAM_REMOTE_USER";
createLogs(var, theAuthRequest);
var = "HTTP_HEADER_OAM_REMOTE_USER";
createLogs(var, theAuthRequest);
}
}

Use SystemRecoverableException
SDK - How to use a SystemRecoverableException to get a trusted variable

Related

Create Folder and Update Title and Custom Field in Sharepoint Online

I try to create folder in sharepoint online, based on some of tutorial. the problem comes since creating folder is not given "Title" column value.
I want to create folder and also update column "Title".
here is the code for create folder
public string CreateDocumentLibrary(string siteUrl, string relativePath)
{
//bool responseResult = false;
string resultUpdate = string.Empty;
string responseResult = string.Empty;
if (siteUrl != _siteUrl)
{
_siteUrl = siteUrl;
Uri spSite = new Uri(siteUrl);
_spo = SpoAuthUtility.Create(spSite, _username, WebUtility.HtmlEncode(_password), false);
}
string odataQuery = "_api/web/folders";
byte[] content = ASCIIEncoding.ASCII.GetBytes(#"{ '__metadata': { 'type': 'SP.Folder' }, 'ServerRelativeUrl': '" + relativePath + "'}");
string digest = _spo.GetRequestDigest();
Uri url = new Uri(String.Format("{0}/{1}", _spo.SiteUrl, odataQuery));
// Set X-RequestDigest
var webRequest = (HttpWebRequest)HttpWebRequest.Create(url);
webRequest.Headers.Add("X-RequestDigest", digest);
// Send a json odata request to SPO rest services to fetch all list items for the list.
byte[] result = HttpHelper.SendODataJsonRequest(
url,
"POST", // reading data from SP through the rest api usually uses the GET verb
content,
webRequest,
_spo // pass in the helper object that allows us to make authenticated calls to SPO rest services
);
string response = Encoding.UTF8.GetString(result, 0, result.Length);
if (response != null)
{
//responseResult = true;
responseResult = response;
}
return responseResult;
}
I already tried to use CAML, but, the problem is, the list of sharepoint is big, so got the error prohibited access related to limit tresshold.
Please help.
Refer below code to update folder name.
function renameFolder(webUrl,listTitle,itemId,name)
{
var itemUrl = webUrl + "/_api/Web/Lists/GetByTitle('" + listTitle + "')/Items(" + itemId + ")";
var itemPayload = {};
itemPayload['__metadata'] = {'type': getItemTypeForListName(listTitle)};
itemPayload['Title'] = name;
itemPayload['FileLeafRef'] = name;
var additionalHeaders = {};
additionalHeaders["X-HTTP-Method"] = "MERGE";
additionalHeaders["If-Match"] = "*";
return executeJson(itemUrl,"POST",additionalHeaders,itemPayload);
}
function getItemTypeForListName(name) {
return"SP.Data." + name.charAt(0).toUpperCase() + name.slice(1) + "ListItem";
}

How to escape characters in Azure Table queries?

I want to query for rows where a column named message starts with: metric="foo"
I tried encoding = and " with percentage and hex codes but it did not work.
Microsoft documentations says special characters must be encoded but does not tell how: https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#query-string-encoding
What should the query look like when value being compared contains special characters?
If you're using azure sdk, then the sdk already did the tricky for you.
In my test, I'm using the latest azure table storage sdk Microsoft.Azure.Cosmos.Table, version 1.0.4.
The test code:
static void Main(string[] args)
{
string connstr = "xxxx";
var storageAccount = CloudStorageAccount.Parse(connstr);
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("myCustomer123");
TableQuery<CustomerEntity> query = new TableQuery<CustomerEntity>();
string myfilter = TableQuery.CombineFilters(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "ivan"),
TableOperators.And,
//for metric="foo", like below.
TableQuery.GenerateFilterCondition("PhoneNumber", QueryComparisons.Equal, "metric=\"foo\"")
);
query.FilterString = myfilter;
var items = table.ExecuteQuery(query);
foreach (var item in items)
{
Console.WriteLine(item.RowKey);
Console.WriteLine(item.PhoneNumber);
}
Console.WriteLine("*****end******");
Console.ReadLine();
}
Test result:
If you want to use the parameter to filter results, you can use ?$filter=<your parameter>%20eq%20'<vaule>'. For example
var date = DateTime.Now.ToUniversalTime().AddYears(1).ToString("R");
var CanonicalizedResource = "/" + StorageAccountName + "/people";
var StringToSign = date + "\n" + CanonicalizedResource;
// List the containers in a storage account.
// ListContainersAsyncREST(StorageAccountName, StorageAccountKey, CancellationToken.None).GetAwaiter().GetResult();
var hmacsha = new HMACSHA256();
hmacsha.Key = Convert.FromBase64String(StorageAccountKey);
var sig= hmacsha.ComputeHash(UTF8Encoding.UTF8.GetBytes(StringToSign));
var sig1 = Convert.ToBase64String(sig);
Console.WriteLine(sig1);
String uri = "https://jimtestperfdiag516.table.core.windows.net/people" + "?$filter=PartitionKey%20eq%20'Jim'";
HttpClient client = new HttpClient();
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri);
httpRequestMessage.Headers.Add("x-ms-date", date);
var str = "SharedKeyLite " + StorageAccountName + ":" + sig1;
httpRequestMessage.Headers.TryAddWithoutValidation("Authorization", str);
httpRequestMessage.Headers.Add("x-ms-version", "2017-04-17");
httpRequestMessage.Headers.Add("Accept", "application/json;odata=fullmetadata");
var results = client.SendAsync(httpRequestMessage).Result;
var response = results.Content.ReadAsStringAsync().Result;
var objs = JsonConvert.DeserializeObject(response);
Console.WriteLine(objs);

I have free DocuSign Signature Appliance Developer Sandbox account.but can not perform signature operation using DssSign

I have a free DocuSign Signature Appliance Developer Sandbox account.I want to use "https://prime.cosigntrial.com:8080/SAPIWS/dss.asmx" and wan to use DssSign service method to create and attach signature to pdf.But it reutrn "urn:oasis:names:tc:dss:1.0:resultmajor:ResponderError".Please help how can I get username and password to create a new signature programmatically and assign to a pdf using DocuSign API
I already download the code samples found Git "docusign-signature-appliance-api-recipes-master" but can not sucess.
//Sign PDF file
public bool SignPDFFile(
string FileToSign,
string UserName,
string Password,
int X,
int Y,
int Width,
int Height,
int Page,
bool isVisible)
{
//Create Request object contains signature parameters
RequestBaseType Req = new RequestBaseType();
Req.OptionalInputs = new RequestBaseTypeOptionalInputs();
//Here Operation Type is set: Verify/Create Signature Field/Sign/etc
Req.OptionalInputs.SignatureType = SignatureTypeFieldCreateSign;
//Configure Create and Sign operation parameters:
Req.OptionalInputs.ClaimedIdentity = new ClaimedIdentity();
Req.OptionalInputs.ClaimedIdentity.Name = new NameIdentifierType();
Req.OptionalInputs.ClaimedIdentity.Name.Value = UserName; //User Name
Req.OptionalInputs.ClaimedIdentity.Name.NameQualifier = " "; //Domain (relevant for Active Directory environment only)
Req.OptionalInputs.ClaimedIdentity.SupportingInfo = new CoSignAuthDataType();
Req.OptionalInputs.ClaimedIdentity.SupportingInfo.LogonPassword = Password; //User Password
Req.OptionalInputs.SAPISigFieldSettings = new SAPISigFieldSettingsType();
Req.OptionalInputs.SAPISigFieldSettings.X = X; //Signature Field X coordinate
Req.OptionalInputs.SAPISigFieldSettings.XSpecified = true;
Req.OptionalInputs.SAPISigFieldSettings.Y = Y; //Signature Field Y coordinate
Req.OptionalInputs.SAPISigFieldSettings.YSpecified = true;
Req.OptionalInputs.SAPISigFieldSettings.Page = Page; //Page number the signature field will appear on
Req.OptionalInputs.SAPISigFieldSettings.PageSpecified = true;
Req.OptionalInputs.SAPISigFieldSettings.Width = Width; //Signature Field width
Req.OptionalInputs.SAPISigFieldSettings.WidthSpecified = true;
Req.OptionalInputs.SAPISigFieldSettings.Height = Height; //Signature Field Height
Req.OptionalInputs.SAPISigFieldSettings.HeightSpecified = true;
Req.OptionalInputs.SAPISigFieldSettings.Invisible = !isVisible; //Specifies whether the signature will be visible or not
Req.OptionalInputs.SAPISigFieldSettings.InvisibleSpecified = true;
// Set configuration parameters /////////////////////////////////////////////////////////
int numConfigurationParams = 6;
Req.OptionalInputs.ConfigurationValues = new ConfValueType[numConfigurationParams];
for (int i = 0; i < numConfigurationParams; i++)
{
Req.OptionalInputs.ConfigurationValues[i] = new ConfValueType();
}
// Add reason
Req.OptionalInputs.ConfigurationValues[0].ConfValueID = ConfIDEnum.Reason;
Req.OptionalInputs.ConfigurationValues[0].Item = "I am the author of this document";
// Add TSA:
/*
Req.OptionalInputs.ConfigurationValues[1].ConfValueID = ConfIDEnum.UseTimestamp;
Req.OptionalInputs.ConfigurationValues[1].Item = 1;
Req.OptionalInputs.ConfigurationValues[2].ConfValueID = ConfIDEnum.TimestampURL;
Req.OptionalInputs.ConfigurationValues[2].Item = "http://www.ca-soft.com/request.aspx";
Req.OptionalInputs.ConfigurationValues[3].ConfValueID = ConfIDEnum.TimestampAdditionalBytes;
Req.OptionalInputs.ConfigurationValues[3].Item = 4000;
Req.OptionalInputs.ConfigurationValues[4].ConfValueID = ConfIDEnum.TimestampUser;
Req.OptionalInputs.ConfigurationValues[4].Item = "";
Req.OptionalInputs.ConfigurationValues[5].ConfValueID = ConfIDEnum.TimestampPWD;
Req.OptionalInputs.ConfigurationValues[5].Item = "";
// OCSP (NOTE: Server must contain comodo CA in order to use the following OCSP URL)
Req.OptionalInputs.ConfigurationValues[4].ConfValueID = ConfIDEnum.UseOCSP;
Req.OptionalInputs.ConfigurationValues[4].Item = 1;
Req.OptionalInputs.ConfigurationValues[5].ConfValueID = ConfIDEnum.OCSPURL;
Req.OptionalInputs.ConfigurationValues[5].Item = "ocsp.comodoca.com";
*/
// End setting configuration parameters ////////////////////////////////////////////////
//Set Session ID
Req.RequestID = Guid.NewGuid().ToString();
//Prepare the Data to be signed
DocumentType doc1 = new DocumentType();
DocumentTypeBase64Data b64data = new DocumentTypeBase64Data();
Req.InputDocuments = new RequestBaseTypeInputDocuments();
Req.InputDocuments.Items = new object[1];
b64data.MimeType = "application/pdf"; //Can also be: application/msword, image/tiff, pplication/octet-string (ocsp/tsa are supported in PDF only)
Req.OptionalInputs.ReturnPDFTailOnlySpecified = true;
Req.OptionalInputs.ReturnPDFTailOnly = true;
b64data.Value = ReadFile(FileToSign, true); //Read the file to the Bytes Array
doc1.Item = b64data;
Req.InputDocuments.Items[0] = doc1;
//Call sign service
ResponseBaseType Resp = null;
try
{
// Create the Web Service client object
DSS service = new DSS();
service.Url = "https://prime.cosigntrial.com:8080/SAPIWS/dss.asmx"; //This url is constant and shouldn't be changed
// service.Url = "https://prime-dsa-devctr.docusign.net:8080/sapiws/dss.asmx"; //This url is constant and shouldn't be changed
SignRequest sreq = new SignRequest();
sreq.InputDocuments = Req.InputDocuments;
sreq.OptionalInputs = Req.OptionalInputs;
//Perform Signature operation
Resp = service.DssSign(sreq);
if (Resp.Result.ResultMajor != Success )
{
MessageBox.Show("Error: " + Resp.Result.ResultMajor + " " +
Resp.Result.ResultMinor + " " +
Resp.Result.ResultMessage.Value, "Error");
return false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
if (ex is WebException)
{
WebException we = ex as WebException;
WebResponse webResponse = we.Response;
if (webResponse != null)
MessageBox.Show(we.Response.ToString(), "Web Response");
}
return false;
}
//Handle Reply
DssSignResult sResp = (DssSignResult) Resp;
//object sig = sResp.SignatureObject.Item;
//SignatureObjectTypeBase64Signature sig = (SignatureObjectTypeBase64Signature) sResp.SignatureObject.Item;
DssSignResultSignatureObjectBase64Signature sig = (DssSignResultSignatureObjectBase64Signature)sResp.SignatureObject.Item;
byte[] signature = sig.Value;
return PDFAttachSignature(FileToSign, signature, true); //Attach Signature to the PDF file
}
display error urn:oasis:names:tc:dss:1.0:resultmajor:ResponderError

Constructing an Account SAS (Shared Access Signature)

I am trying to generate Account SAS token:
MSDN DOC
When I am trying to use generated token, I get following:
AuthenticationFailed
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:89959111-0001-00c8-24d1-e0515b000000
Time:2016-07-18T08:49:00.8383767Z
Signature did not match. String to sign used was [accountName]
rl
b
sc
2017-01-01
2015-04-05
Here are my code:
var signedVersion = "2015-04-05";
var signedServices = "b";
var signedResourceTypes = "sc";
var signedPermission = "rl";
var signedExpiry = "2017-01-01";
var stringToSign =
accountName + "\n" +
signedPermission + "\n" +
signedServices + "\n" +
signedResourceTypes + "\n" +
signedExpiry + "\n" +
signedVersion + "\n"
;
var keyBytes = Encoding.UTF8.GetBytes(accountKey);
byte[] hash;
using (var mac = new HMACSHA256(keyBytes))
{
var stringToSignBytes = Encoding.UTF8.GetBytes(stringToSign);
hash = mac.ComputeHash(stringToSignBytes);
}
var str = Convert.ToBase64String(hash);
var sig = HttpUtility.UrlEncode(str);
var url = $"https://{accountName}.blob.core.windows.net/?comp=list&sv={signedVersion}&ss={signedServices}&srt={signedResourceTypes}&sp={signedPermission}&se={signedExpiry}&sig={sig}";
What am I doing wrong?
I noticed a few issues with the code:
First, to convert account key into byte array you would need to use Convert.FromBase64String(accountKey) instead of Encoding.UTF8.GetBytes(accountKey);.
Next, even if you're not using start time, signed protocol and signed IP addresses, you would need to include them in your stringToSign.
Once you do these things, the code should work. Based on these, I have included the modified code below. I tested it for listing containers in my storage account and it works.
static void AccountSas()
{
var signedVersion = "2015-04-05";
var signedServices = "b";
var signedResourceTypes = "sc";
var signedPermission = "rl";
var signedExpiry = "2017-01-01";
var signedStart = "";
var signedIP = "";
var signedProtocol = "";
var stringToSign =
accountName + "\n" +
signedPermission + "\n" +
signedServices + "\n" +
signedResourceTypes + "\n" +
signedStart + "\n" +
signedExpiry + "\n" +
signedIP + "\n" +
signedProtocol + "\n" +
signedVersion + "\n"
;
var keyBytes = Convert.FromBase64String(accountKey);
byte[] hash;
using (var mac = new HMACSHA256(keyBytes))
{
var stringToSignBytes = Encoding.UTF8.GetBytes(stringToSign);
hash = mac.ComputeHash(stringToSignBytes);
}
var str = Convert.ToBase64String(hash);
var sig = HttpUtility.UrlEncode(str);
var url = string.Format("https://{0}.blob.core.windows.net/?comp=list&sv={1}&ss={2}&srt={3}&sp={4}&se={5}&sig={6}", accountName, signedVersion, signedServices, signedResourceTypes, signedPermission, signedExpiry, sig);
}

Azure server not letting me use a NuGet package

I have a website hosted by Azure that includes a Web API which I'm using to develop an android app. I'm trying to upload a media file to the server where it's encoded by a media encoder and saved to a path. The encoder library is called "Media Toolkit" which I found here : https://www.nuget.org/packages/MediaToolkit/1.0.0.3
My server side code looks like this:
[HttpPost]
[Route("upload")]
public async Task<HttpResponseMessage> Upload(uploadFileModel model)
{
var result = new HttpResponseMessage(HttpStatusCode.OK);
if (ModelState.IsValid)
{
string thumbname = "";
string resizedthumbname = Guid.NewGuid() + "_yt.jpg";
string FfmpegPath = Encoding_Settings.FFMPEGPATH;
string tempFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~/video"), model.fileName);
string pathToFiles = HttpContext.Current.Server.MapPath("~/video");
string pathToThumbs = HttpContext.Current.Server.MapPath("~/contents/member/" + model.username + "/thumbs");
string finalPath = HttpContext.Current.Server.MapPath("~/contents/member/" + model.username + "/flv");
string resizedthumb = Path.Combine(pathToThumbs, resizedthumbname);
var outputPathVid = new MediaFile { Filename = Path.Combine(finalPath, model.fileName) };
var inputPathVid = new MediaFile { Filename = Path.Combine(pathToFiles, model.fileName) };
int maxWidth = 380;
int maxHeight = 360;
var namewithoutext = Path.GetFileNameWithoutExtension(Path.Combine(pathToFiles, model.fileName));
thumbname = model.VideoThumbName;
string oldthumbpath = Path.Combine(pathToThumbs, thumbname);
var fileName = model.fileName;
try
{
File.WriteAllBytes(tempFilePath, model.data);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
using (var engine = new Engine())
{
engine.GetMetadata(inputPathVid);
// Saves the frame located on the 15th second of the video.
var outputPathThumb = new MediaFile { Filename = Path.Combine(pathToThumbs, thumbname + ".jpg") };
var options = new ConversionOptions { Seek = TimeSpan.FromSeconds(0), CustomHeight = 360, CustomWidth = 380 };
engine.GetThumbnail(inputPathVid, outputPathThumb, options);
}
Image image = Image.FromFile(Path.Combine(pathToThumbs, thumbname + ".jpg"));
//var ratioX = (double)maxWidth / image.Width;
//var ratioY = (double)maxHeight / image.Height;
//var ratio = Math.Min(ratioX, ratioY);
var newWidth = (int)(maxWidth);
var newHeight = (int)(maxHeight);
var newImage = new Bitmap(newWidth, newHeight);
Graphics.FromImage(newImage).DrawImage(image, 0, 0, newWidth, newHeight);
Bitmap bmp = new Bitmap(newImage);
bmp.Save(Path.Combine(pathToThumbs, thumbname + "_resized.jpg"));
//File.Delete(Path.Combine(pathToThumbs, thumbname));
using (var engine = new Engine())
{
var conversionOptions = new ConversionOptions
{
VideoSize = VideoSize.Hd720,
AudioSampleRate = AudioSampleRate.Hz44100,
VideoAspectRatio = VideoAspectRatio.Default
};
engine.GetMetadata(inputPathVid);
engine.Convert(inputPathVid, outputPathVid, conversionOptions);
}
File.Delete(tempFilePath);
Video_Struct vd = new Video_Struct();
vd.CategoryID = 0; // store categoryname or term instead of category id
vd.Categories = "";
vd.UserName = model.username;
vd.Title = "";
vd.Description = "";
vd.Tags = "";
vd.Duration = inputPathVid.Metadata.Duration.ToString();
vd.Duration_Sec = Convert.ToInt32(inputPathVid.Metadata.Duration.Seconds.ToString());
vd.OriginalVideoFileName = model.fileName;
vd.VideoFileName = model.fileName;
vd.ThumbFileName = thumbname + "_resized.jpg";
vd.isPrivate = 0;
vd.AuthKey = "";
vd.isEnabled = 1;
vd.Response_VideoID = 0; // video responses
vd.isResponse = 0;
vd.isPublished = 1;
vd.isReviewed = 1;
vd.Thumb_Url = "none";
//vd.FLV_Url = flv_url;
vd.Embed_Script = "";
vd.isExternal = 0; // website own video, 1: embed video
vd.Type = 0;
vd.YoutubeID = "";
vd.isTagsreViewed = 1;
vd.Mode = 0; // filter videos based on website sections
//vd.ContentLength = f_contentlength;
vd.GalleryID = 0;
long videoid = VideoBLL.Process_Info(vd, false);
return result;
}
else
{
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted"));
}
}
When the debugger hits the line using (var engine = new Engine()) I get 500 internal server error thrown. I don't get this error testing it on the iis server. Since it works fine on my local server and not on the azure hosted server, I figured it had to do with the Azure service rather than an error in my code. If so is the case then how would I be able to get around this issue? I don't want to use azure blob storage as it would require a lot of changes to my code. Does anyone have any idea what might be the issue.
Any helpful suggestions are appreciated.
Server.MapPath works differently on Azure WebApps - change to:
string pathToFiles = HttpContext.Current.Server.MapPath("~//video");
Also, see this SO post for another approach.

Resources