Reputation: 454
I'm trying to build a web application in C# that can get the latest version of a file from a tfs server. That file with then be edited and etc...
Right now I get permission errors when trying to download a file using
IIdentity WinId = HttpContext.Current.User.Identity;
WindowsIdentity wi = (WindowsIdentity)WinId;
WindowsImpersonationContext wic = wi.Impersonate();
that code. After that I do a connection to the TFS Team Project Collection using:
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new
Uri("http://tfs:8080/tfs/DefaultCollection"));
which works fine. I can use PendEdit, get the workspace, get pending changes, everything. However I cannot do:
SourceControl.DownloadFile(serverFilePath, localFilePath);
I have tried a local path both in my workspace and in a newly created workspace both with same result
I will always get permission denied (To be exact I get this -> TF30063: You are not authorized to access Microsoft-IIS/7.5.) SourceControl is defined properly and I have full permission to my local folder and on TFS. I can get latest by right clicking the file and saying get latest I just can't do it in the app.
Any suggestions/problems with what I'm doing?
If I can't do this using just the impersonate stuff how do you prompt for credentials each time?
Upvotes: 0
Views: 330
Reputation: 10120
SourceControl.DownloadFile(serverFilePath, localFilePath);
The localFilePath that you are mentioning above, is it same as the Workspace path or some other path? Can you try to mention the workspace path of the file and try the method?
Upvotes: 0