1 Replies - 1075 Views - Last Post: 21 November 2012 - 04:09 AM Rate Topic: -----

#1 naush83  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-November 12

How to write a file using XmlTextWriter by passing different network c

Posted 21 November 2012 - 01:48 AM

Hi,

I use XmlTextWriter to build a simple xml and trying to write it to a network shared folder. Only a particular user, which is different from the user currently running the aps.net application, has the WRITE permission on the shared folder. I have the username and password of this privileged network user acount. But I don't know how do I pass the credentials to the XmlTextWriter object. Please advise. Appreciate your help.

Here is the code: - It throws 'Access to the path is denied'.

XmlTextWriter wt = new XmlTextWriter(@"\\myserver\MySharedFolder\\Test.xml", System.Text.Encoding.UTF8);
wt.Formatting = Formatting.Indented;
wt.WriteStartDocument();
wt.WriteStartElement("Titles");
wt.WriteStartElement("Title");

wt.WriteElementString("title", "JobA");
wt.WriteElementString("JobId","201");
wt.WriteElementString("Client", "ABC");

wt.WriteEndElement();

wt.WriteEndElement();

wt.Close();


To be more specific: I have a shared folder which allows only a particular user, say 'User A' to write files to it. But my asp.net application runs in a different user, say User B, which has no WRITE permission to the shared folder. Unfortunately I can't give write access to the user account User B in my specific scenario for some valid reason. Now the question is, how do I write a text file to the above mentioned shared folder from my asp.net application, if the password of user account User-A is given?

This post has been edited by JackOfAllTrades: 21 November 2012 - 04:09 AM
Reason for edit:: Added code tags


Is This A Good Question/Topic? 0
  • +

Replies To: How to write a file using XmlTextWriter by passing different network c

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6064
  • View blog
  • Posts: 23,520
  • Joined: 23-August 08

Re: How to write a file using XmlTextWriter by passing different network c

Posted 21 November 2012 - 04:09 AM

Impersonation?

Moved to ASP.NET
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1