Hi all,
Is there any class in .NET 1.x that will help me set file & folder
permissions for a user? Aka - I would like to do the in code equivalent of
right clicking a folder in file explorer and granting read/write access to a
specific user {not the user running the program}.
Any ideas? Or am I going to have to PInvoke like crazy?? 4 2677
Richard,
Unfortunately, your latter question is the answer. There is no managed
way (at least out-of-the-box) to set permissions on a file/folder in .NET
1.1, except through calls to P/Invoke.
.NET 2.0, makes this very easy, however.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Richard" <Ri*****@discussions.microsoft.com> wrote in message
news:50**********************************@microsof t.com... Hi all,
Is there any class in .NET 1.x that will help me set file & folder permissions for a user? Aka - I would like to do the in code equivalent of right clicking a folder in file explorer and granting read/write access to a specific user {not the user running the program}.
Any ideas? Or am I going to have to PInvoke like crazy??
There two managed way's to set permissions on ACL protected objects (files,
registry key's, etc..), the first is by using the System.Management classes
the second System.Directory services (which can also be used to manage AD
object ACL's), or do you consider these as not managed?
Willy.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eU**************@TK2MSFTNGP14.phx.gbl... Richard,
Unfortunately, your latter question is the answer. There is no managed way (at least out-of-the-box) to set permissions on a file/folder in .NET 1.1, except through calls to P/Invoke.
.NET 2.0, makes this very easy, however.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Richard" <Ri*****@discussions.microsoft.com> wrote in message news:50**********************************@microsof t.com... Hi all,
Is there any class in .NET 1.x that will help me set file & folder permissions for a user? Aka - I would like to do the in code equivalent of right clicking a folder in file explorer and granting read/write access to a specific user {not the user running the program}.
Any ideas? Or am I going to have to PInvoke like crazy??
They are managed, but it's not exactly what I would call "finished". My
initial response was false in the sense that yes, there is a managed way,
but choosing between WMI and the P/Invoke layer in this case is a toss-up,
IMO.
You have the advantage of being able to create strongly-typed classes
from the WMI classes, which might be just as easy as cutting and pasting the
needed declarations from http://www.pinvoke.net (depending on if the needed
APIs and supporting structures are there or not).
It all depends on what the OP is more comfortable with.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:ex**************@TK2MSFTNGP10.phx.gbl... There two managed way's to set permissions on ACL protected objects (files, registry key's, etc..), the first is by using the System.Management classes the second System.Directory services (which can also be used to manage AD object ACL's), or do you consider these as not managed?
Willy.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:eU**************@TK2MSFTNGP14.phx.gbl... Richard,
Unfortunately, your latter question is the answer. There is no managed way (at least out-of-the-box) to set permissions on a file/folder in .NET 1.1, except through calls to P/Invoke.
.NET 2.0, makes this very easy, however.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Richard" <Ri*****@discussions.microsoft.com> wrote in message news:50**********************************@microsof t.com... Hi all,
Is there any class in .NET 1.x that will help me set file & folder permissions for a user? Aka - I would like to do the in code equivalent of right clicking a folder in file explorer and granting read/write access to a specific user {not the user running the program}.
Any ideas? Or am I going to have to PInvoke like crazy??
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Ol**************@TK2MSFTNGP14.phx.gbl... They are managed, but it's not exactly what I would call "finished". My initial response was false in the sense that yes, there is a managed way, but choosing between WMI and the P/Invoke layer in this case is a toss-up, IMO.
You have the advantage of being able to create strongly-typed classes from the WMI classes, which might be just as easy as cutting and pasting the needed declarations from http://www.pinvoke.net (depending on if the needed APIs and supporting structures are there or not).
It all depends on what the OP is more comfortable with.
Hmm... to me it's clear when I read this:Any ideas? Or am I going to have to PInvoke like crazy??
Anyway, why a toss-up and why are they not finished?
In what way are they different from lets say System.Data.Odbc or
System.Data.OleDb namespace, both wrap unmanaged code (COM and native DLL
exports) to access local/remote DB server resources, both present
functionality to present the data to a consumer in an OO way. Granted
System.Management could do a lot more in managed code (like MS did with
SqlClient, where they removed the COM layer) before transitioning into
unmanaged code, but the difference here is that for SqlClient it was
"critical" move performance wise, while for System.Management this is much
less of an issue.
If you really consider PInvoke as a viable alternative I have to disagree,
if you find yourself defining several PInvoke signatures in a piece of user
code (not framework classes though) you probably overlooked a managed
equivalent (or you consider it as not finished :-)), or you are using the
wrong language. Native C style API's belong to C, managed OO oriented API's
are what you need from managed user code, or simply put, PInvoke is
something that belongs in frameworks that are maintained by the same vendor
as the native API's, when these change (in terms of signature, behavior,
constraints, etc...) or when they get removed the framework should be
adapted as well, and this is the vendors responsibility. Note also that many
Win32 API's have security constraints that are not well understood by many
developers, that means that instead of calling a limited number of API's you
end with calling a lot more API's because you need to impersonate (if it's
possible - remember calling LogonUser on W2K?) and/or you need to elevate
user privileges before you can actually do something as simple as changing
ACL's of some kernel objects. Really, this is something that should be
wrapped in the framework, the upcoming v2.0 frameworks offers this
functionality for the most common objects like files, but still it lacks
some features offered by System.Management.
Willy.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message news:ex**************@TK2MSFTNGP10.phx.gbl... There two managed way's to set permissions on ACL protected objects (files, registry key's, etc..), the first is by using the System.Management classes the second System.Directory services (which can also be used to manage AD object ACL's), or do you consider these as not managed?
Willy.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:eU**************@TK2MSFTNGP14.phx.gbl... Richard,
Unfortunately, your latter question is the answer. There is no managed way (at least out-of-the-box) to set permissions on a file/folder in .NET 1.1, except through calls to P/Invoke.
.NET 2.0, makes this very easy, however.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Richard" <Ri*****@discussions.microsoft.com> wrote in message news:50**********************************@microsof t.com... Hi all,
Is there any class in .NET 1.x that will help me set file & folder permissions for a user? Aka - I would like to do the in code equivalent of right clicking a folder in file explorer and granting read/write access to a specific user {not the user running the program}.
Any ideas? Or am I going to have to PInvoke like crazy??
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Fran Tirimo |
last post by:
I am developing a small website using ASP scripts to format data retrieved
from an Access database. It will run on a Windows 2003 server supporting
FrontPage extensions 2002 hosted by the company...
|
by: Fran Tirimo |
last post by:
I am developing a small website using ASP scripts to format data retrieved
from an Access database. It will run on a Windows 2003 server supporting
FrontPage extensions 2002 hosted by the company...
|
by: Dave Y |
last post by:
Hello,
I am new to ASP as well as IIS. I am trying to learn how to create a web
application using asp.NET. I have followed the instructions for configuring
the IIS settings but when I click on...
|
by: Mark C. |
last post by:
I'm trying to call a batch file that I've built using the FileSystemObject
and CreateObject("Wscript.Shell"), oShell.Run... in an asp script.
Naturally, I can get the script to work from a command...
|
by: sur |
last post by:
Hello,
My problem is that File.Exists works fine if my file is on my local
drive but returns false if its on any other drive. I think that the
issue is probably file permissions and so I have...
|
by: BlueFrog |
last post by:
Hi all,
I'd appreciate some ideas on this as I've just spent the last 2 hours trying
to solve it to no avail.
I'm am building a web application which includes the functionality to upload...
|
by: David Thielen |
last post by:
Hi;
My ASP.NET app (C# calling J# under .net 2.0) creates a png file in a
subdirectory to display as part of the created page. However, the bitmap will
not display due to a security violation.
...
|
by: rn5a |
last post by:
I am using the following connection to connect to a MS-Access
database:
---------------------------------
set con = server.createObject("adodb.connection")
path1 = ...
|
by: Tony B |
last post by:
I've moved an existing site (which I didn't write) from a apache/php/mysql
host under windows to a linux apache/php/mysql host.
I've sorted out most problems except one.
There is an upload...
|
by: chrisj |
last post by:
I'm using freeASPupload and got some assistance integrating to a Member script. It works successfully.
In this modified version there are two groups that use this upload script. Members of one...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |