Converting Win32 API to VB.NET for Folder Security

Discussion in 'ASP .Net Security' started by i23bam, May 25, 2004.

  1. i23bam

    i23bam Guest

    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?
    i23bam, May 25, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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?
    Joe Kaplan \(MVP - ADSI\), May 26, 2004
    #2
    1. Advertising

  3. i23bam

    i23bam Guest

    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.
    i23bam, May 26, 2004
    #3
  4. 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" <> wrote in message
    news:...
    > 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.
    Joe Kaplan \(MVP - ADSI\), May 27, 2004
    #4
  5. i23bam

    [MSFT] Guest

    [MSFT], Jun 2, 2004
    #5
  6. i23bam

    i23bam Guest

    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.
    i23bam, Jun 4, 2004
    #6
  7. 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" <> wrote in message
    news:...
    > Are there any other suggestions for a solution?
    >
    > "i23bam" wrote:
    >
    > > 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.
    Joe Kaplan \(MVP - ADSI\), Jun 23, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. chapman

    ASP.NET + WIN32 API

    chapman, Jul 25, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    510
    chapman
    Jul 28, 2003
  2. Chapman

    Security concern to block Win32 API in ASP.NET?

    Chapman, Jul 28, 2003, in forum: ASP .Net Security
    Replies:
    0
    Views:
    137
    Chapman
    Jul 28, 2003
  3. Dinis Cruz
    Replies:
    1
    Views:
    217
    Susan Bradley, CPA aka Ebitz - SBS Rocks [MVP]
    Oct 17, 2003
  4. Thomas Thomassen
    Replies:
    2
    Views:
    142
    Thomas Thomassen
    Dec 29, 2010
  5. Oistein Sorensen

    Converting a VB typdef to Win32::API::Struct

    Oistein Sorensen, Sep 30, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    99
    Bart Lateur
    Sep 30, 2003
Loading...

Share This Page