CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005
    Posts
    35

    Permissions problem deleting folders

    I'm coding in C#, but I think the issue is more of a general Windows programming issue than C# specific.

    I am writing a program to clean up the residue of deleted accounts and what I'm trying to delete are extraneous profiles (ie., a profile with no corresponding account). The program runs on a domain controller and the profiles are on another server which is just a domain member. I can delete the profiles from that server directly, but when I try to delete them via program control from the domain controller, using the full UNC, I get permission denied errors. I am doing (more like trying to do) a recursive delete using the DirectoryInfo.delete(true) syntax in C#.

    Is there something special I need go do because these are profiles? Any suggestions would be most appreciated.

    Thanks,
    Rob

  2. #2
    Join Date
    May 2002
    Location
    Texas
    Posts
    222

    Re: Permissions problem deleting folders

    I can delete the profiles from that server directly, but when I try to delete them via program control from the domain controller, using the full UNC, I get permission denied errors.
    This almost always indicates that the security context your program is running under does not have the same rights to delete files as your ID does.

    It sounds like you are having your program launched by some other process rather than launching it while you are logged in under your ID.

  3. #3
    Join Date
    Feb 2005
    Posts
    35

    Re: Permissions problem deleting folders

    Just to test for the possibility of it being a security context issue, I invoked the C# program from the command line and again got the permission denied error. I then attempted to delete the profile from within the same command window using the DOS rmdir /S command with the full UNC path to the profile on the other system. It asked me if I was sure and then successfully deleted the directory -- no permissions issues.

    So, if it is a security context issue, that would mean that a .NET program runs under a different context than the user that invoked it, even though it was invoked from a command prompt. Is that the case? And if so, where do I look to fix it?

    Thanks,
    Rob

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