473,382 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How can I modify the user rigths on a xml file?

Hello NG,

How can I modify the user rigths on a xml file?
Can this be done by code as well?

I could only find the possibillity to modify user rights on folders, not on
files and this onyl manual.

Regards
Rainer Queck
Sep 26 '07 #1
5 1303
"Rainer Queck" <Ra****@noemail.noemailwrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl...
Hi Michael,

thanks for the link! That should make it fairly easy :-)

Regards
Rainer
Don't use this method if you have access to V2 of the framework, use the
System.Security.AccessControl
namespace classes instead.
Also keep in mind that changing the security settings on Filesystem objects
(and others) requires administrative privileges, your applications don't
require to run as administrator do they?

Willy.

Sep 26 '07 #2
Hi Rainer,

Thank you for the feedback.

Is your code using .Net1.1 or 2.0?

The code snippet link provided by "Michael Nemtsev" leverages the
gotdotnet code sample. The gotdotnet code sample is provided to address the
lack of file security support in .Net1.1. In .Net2.0, we have added the
build-in support for configuring the security setting for directories and
files. That's why Willy suggested you to use the build-in
System.Security.AccessControl namespace for your task if you are using
Net2.0.

In .Net2.0, setting the user rights on a file is pretty straightforward.
You may use File.GetAccessControl() to obtain the current security setting
of the file as a FileSecurity object. Then, you may use
FileSecurity.AddAccessRule() and FileSecurity.RemoveAccessRule() methods to
add or remove rules from the FileSecurity object. Finally, you can use
File.SetAccessControl() method to assign the new FileSecurity to the file.

There is sample code snippet in the link below:
http://msdn2.microsoft.com/en-us/lib...esscontrol.asp
x

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 27 '07 #3
Hello Jeffrey,

""Jeffrey Tan[MSFT]"" <je***@online.microsoft.comschrieb im Newsbeitrag
news:wm*************@TK2MSFTNGHUB02.phx.gbl...
Is your code using .Net1.1 or 2.0?
I am using 2.0.
The code snippet link provided by "Michael Nemtsev" leverages the
gotdotnet code sample. The gotdotnet code sample is provided to address
the
lack of file security support in .Net1.1. In .Net2.0, we have added the
build-in support for configuring the security setting for directories and
files. That's why Willy suggested you to use the build-in
System.Security.AccessControl namespace for your task if you are using
Net2.0.

In .Net2.0, setting the user rights on a file is pretty straightforward.
You may use File.GetAccessControl() to obtain the current security setting
of the file as a FileSecurity object. Then, you may use
FileSecurity.AddAccessRule() and FileSecurity.RemoveAccessRule() methods
to
add or remove rules from the FileSecurity object. Finally, you can use
File.SetAccessControl() method to assign the new FileSecurity to the file.

There is sample code snippet in the link below:
http://msdn2.microsoft.com/en-us/lib...esscontrol.asp
Thank you very much for the additional information and link!
I think this makes it very easy now, to implement to my project, what I am
looking for. I am currently thinking to add functionallity, that allows a
user of my app (if he knows the admin access passwords) to readjust the user
rights of the xml-file in question. This might become necessary, because it
is possible, that this file can be moved around different systems since it
holds setup data to a external teststand.

Regards
Rainer Queck
Sep 28 '07 #4
Hi Willy,

thanks for your hints.

"Willy Denoyette [MVP]" <wi*************@telenet.beschrieb im Newsbeitrag
news:Ou**************@TK2MSFTNGP04.phx.gbl...
Also keep in mind that changing the security settings on Filesystem
objects (and others) requires administrative privileges, your applications
don't require to run as administrator do they?
;-)
No they don't...
....but currently I am thinking about adding a feature that would allow the
user in a case like this to readjust the file rights if necessary.

Regards
Rainer
Sep 28 '07 #5
Hi Jeffrey,

""Jeffrey Tan[MSFT]"" <je***@online.microsoft.comschrieb im Newsbeitrag
news:FM**************@TK2MSFTNGHUB02.phx.gbl...
Hope this helps.
Yes, it helped a lot! Thanks for the links.

Regards
Rainer
Oct 1 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: perchef | last post by:
hi, i have written this small code which allow me to unzip files using python : import zipfile import os import os.path pathDir="/home/toto/Desktop"
16
by: Philippe C. Martin | last post by:
Hi, I am trying to change the data in a form field from python. The following code does not crash but has no effect as if "form" is just a copy of the original html form. Must I recreate the...
1
by: Greatfree | last post by:
Dear all, I tried to modify an XML file in a Web Service. After that, I need to save the XML file into a local disk. But I got the following errors. Could you please tell me what's going on...
1
by: VM | last post by:
In my Windows application, I use the streamreader to display a txt file into multi-line textbox and /streamwriter to modify the txt file if the user decides to change the contents through the...
12
by: SStory | last post by:
Doing pages for contract..... If I make an ASPX file that does certain things, how simple would it be for a person who know nothing about it to modify the user interface without bothering the...
12
by: Quentin Huo | last post by:
Hi: I am working in win 2003 and ASP.NET. I tried to modify the user rights from an ASPX (writen in C#) page through running xcacls. But failed. What I did is: Process myProcess = new...
4
by: c++ newbie | last post by:
hello gurus of C++ programming, I am a student doing my masters in computer applications.I am a bit experienced in VB 6.0.I am currently doing a project in vb 6. To accompish a certain task I...
0
by: nkw | last post by:
My Asp.net execute a SSIS package which will modify an MDB file. It always failed. However, I can execute the SSIS package using dtexec. Should I modify the file permissions of the MDB file? If...
9
by: Will | last post by:
I have given up looking for a solution so I figured I would break down and ask. I am trying to modify a CSS class in page_load. I have no problem doing it with an ID with the simple ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.