SQLScholar
Programmer
Hi all,
I have this code:
Which works perfectly (the account used is a domain admin) - unless......
The administrator account has had its permissions removed from the folder.
If i am using the windows front end - i can claim ownership of the folder and then set permissions. However the above will not claim ownership for me. Instead it errors.
er.Message = "Method failed with unexpected error code 87."
Any ideas how i can claim ownership of a folder that i have no permissions (yet because i am admin i can claim permissions.
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
I have this code:
Code:
Private Sub setOwner(ByRef FileName As String, ByRef account As NTAccount)
Try
Dim dInfo As New DirectoryInfo(FileName)
Dim dir As New DirectorySecurity(FileName, AccessControlSections.None)
dir.SetOwner(account)
dInfo.SetAccessControl(dir)
dir = Nothing
dInfo = Nothing
If System.IO.Directory.Exists(FileName) Then
Dim Files As String()
Files = Directory.GetFileSystemEntries(FileName)
For Each element As String In Files
setOwner(element, account)
Next
End If
Catch er As Exception
Writetolog(FileName, "ERROR", "Catch 1 Set owner - " + er.Message)
End Try
End Sub
Which works perfectly (the account used is a domain admin) - unless......
The administrator account has had its permissions removed from the folder.
If i am using the windows front end - i can claim ownership of the folder and then set permissions. However the above will not claim ownership for me. Instead it errors.
er.Message = "Method failed with unexpected error code 87."
Any ideas how i can claim ownership of a folder that i have no permissions (yet because i am admin i can claim permissions.
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------