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'.
Thanks for your reply. I think my question is not clear to you. 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?
naush83
Member
4 Points
19 Posts
How to write a file using XmlTextWriter by passing different network credentials?
Nov 20, 2012 02:05 PM|LINK
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();
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: How to write a file using XmlTextWriter by passing different network credentials?
Nov 21, 2012 01:45 AM|LINK
Hello,
Please make sure that the file path can be accessable,and you have enough permission to access the file.
Reguards!
naush83
Member
4 Points
19 Posts
Re: How to write a file using XmlTextWriter by passing different network credentials?
Nov 21, 2012 07:37 AM|LINK
Hi Mr. Decker,
Thanks for your reply. I think my question is not clear to you. 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?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: How to write a file using XmlTextWriter by passing different network credentials?
Nov 21, 2012 08:02 AM|LINK
Hello,
Maybe user B should be given or told from user A and he/she can edit the file according to the rule of Windows security.
Or maybe user B can create a new file and then override user A's by userA.
Reguards!