Converting Win32 API to VB.NET for Folder Security

I

i23bam

For the record, I am a newbie to API. Anyway, I am trying to use the Win32 API in VB.NET to set NT Security (Administrator ACE) on a remote server folder from within a backup executable I have created. The problem is I am trying to implement my translated version of the NTFS Permission example, at http://www.mentalis.org/apilist/LookupAccountName.shtml, to VB.NET and the code fails at one particular point. (BTW, I have chosen NTFS Permission example because it seems pretty straight forward for a newbie.) I have converted all Longs to Ints and added ByRefs where needed, but the app seems to quit at the AddAce Call (ERROR_INVALID_PARAMETER). Has anyone already converted this code or would anyone have suggestions for a fix?
 
J

Joe Kaplan \(MVP - ADSI\)

Did you try the Win32 security library from GotDotNet
http://www.gotdotnet.com/Community/...mpleGuid=e6098575-dda0-48b8-9abf-e0705af065d9
or the stuff Data Marvel has? There isn't much reason to reinvent these
pinvoke declarations.

Joe K.

i23bam said:
For the record, I am a newbie to API. Anyway, I am trying to use the Win32
API in VB.NET to set NT Security (Administrator ACE) on a remote server
folder from within a backup executable I have created. The problem is I am
trying to implement my translated version of the NTFS Permission example, at
http://www.mentalis.org/apilist/LookupAccountName.shtml, to VB.NET and the
code fails at one particular point. (BTW, I have chosen NTFS Permission
example because it seems pretty straight forward for a newbie.) I have
converted all Longs to Ints and added ByRefs where needed, but the app seems
to quit at the AddAce Call (ERROR_INVALID_PARAMETER). Has anyone already
converted this code or would anyone have suggestions for a fix?
 
I

i23bam

Joe, Yes. I did come across the wrapper class a couple of weeks ago, although the idea was abandoned because I was unsure how to integrate the c# project with my vb.net solution within Visual Studio.NET 2003. Would I have to compile the c# class into a dll and include the dll in my project to use it as an Imports Win32API? Also, if so would I have to migrate the new c# dlls with my final executable in order for it to run on multiple machines? Thank you for all repies in advance.
 
J

Joe Kaplan \(MVP - ADSI\)

Yeah, just include the project in your solution. Then you'll have an exe
(or whatever you were originally building) and another assembly in a DLL
that you need to include with your project.

There is no worry about combining VB and C# projects in the same solution.
I do this all the time when I need to.

Joe K.

i23bam said:
Joe, Yes. I did come across the wrapper class a couple of weeks ago,
although the idea was abandoned because I was unsure how to integrate the c#
project with my vb.net solution within Visual Studio.NET 2003. Would I have
to compile the c# class into a dll and include the dll in my project to use
it as an Imports Win32API? Also, if so would I have to migrate the new c#
dlls with my final executable in order for it to run on multiple machines?
Thank you for all repies in advance.
 
I

i23bam

Luke. Yes. I have taken this option into consideration, however the executable I am using must be portable, thus it must have .dlls inherent in all Windows 98, 2k and XP PCs to allow for its portability. It is for this reason that I chose the Windows API as the solution. I would hate to have to install the ASDI .dll on all machines wanting to backup. I know, however, the users will have to download the .NET package, but the Windows Update procedures make this task fairly simple. I also know that Visual Studio 2005 will have the Security Objects built in, but if I do not have to wait I would like to program for it now.
 
J

Joe Kaplan \(MVP - ADSI\)

Didn't read the rest of the thread, but did you check out the Win32 security
..NET wrapper at gotdotnet or Data Marvel's library?

http://www.gotdotnet.com/Community/...mpleGuid=e6098575-dda0-48b8-9abf-e0705af065d9
http://www.datamarvel.com/

Joe K.

i23bam said:
Are there any other suggestions for a solution?
executable I am using must be portable, thus it must have .dlls inherent in
all Windows 98, 2k and XP PCs to allow for its portability. It is for this
reason that I chose the Windows API as the solution. I would hate to have to
install the ASDI .dll on all machines wanting to backup. I know, however,
the users will have to download the .NET package, but the Windows Update
procedures make this task fairly simple. I also know that Visual Studio 2005
will have the Security Objects built in, but if I do not have to wait I
would like to program for it now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top