CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: NT Security

  1. #1
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Question NT Security

    How could an application write in a file in which the current logged user can not, under Windows NT/2000/XP ?

    This to avoid the accidentally modify/delete this file by an unauthorized user, using notepad, for example.

    Thanks!
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  2. #2
    Join Date
    Aug 2001
    Location
    Stockholm, Sweden
    Posts
    1,664
    You can't do that. The application will only have the rights of the user that started it. You can however implement your program as a NT service.

    Another method is to impersonate a user; doing an interactive login and running the process as another (more powerful) user. But that is more like log out and then log in with another user again.

    There are lots of info about how to write NT service programs (see codeguru articles and the MSDN web site).

    If your app should work more or less like a normal app (having a GUI etc), but needs to protect a file in the way you mentioned, I would implement a very limitted NT service program which only task is the create/write/delete the mentioned file. Your service program and your app need some sort of communication, like named pipes, shared memory, sockets, RPCs or COM.

    Good luck.

    PS. All this only applies to NT/W2K/XP... On Win9x, you can't do much about it :-(

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Lightbulb Thanks

    OK.
    Thank you very much!
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured