We currently have a couple of elements with file handling in one master directory and we are trying to establish a remote location since there will be multiple DMA's on release. We are currently using the ImpersonatedUser class with Interactive privileges with the Microsoft Security namespace and WindowsIdentity class.
We are still encountering strange AccessToPathIsDenied exceptions and AccessDenied exceptions when trying to read files. Also, some elements (running the same protocol) seem to have different privileges as some are able to read and write, others only read, and others none at all.
Another preference would be a method using a System account as opposed to a User account since the password will need to be reset every couple of months and that may be cumbersome for the client to update the passwords on so many elements.
So in short, is there a better way besides the ImpersonatedUser with heightened privileges and able to use a system account to access a remote directory?
Hi Gabriel,
I have a couple questions for you:
1) Are you sure the current implementation with ImpersonatedUser is done correctly? As it seems weird that it behaves differently for other elements from the same protocol. I guess you are pointing to the same shared folder with the same impersonated User/PW configured?
2) I also see your tag on this question indicates "C++". Are you using C++ code accessed via a DLL in the QAction? Or are you coding directly in your QAction in C# and maybe the tag was a typo?
If you could maybe send the protocol over by PM, I can have a quick look at it.
1 – I believe it is the correct implementation as I have compared it to many examples from StackOverflow and the Microsoft website and it seems to be the same code. Also, it is reused code from the Microsoft Platform driver which does not have issues with the ImpersonatedUser class.
2 – Yes, it was a typo. I believe it is a bug on Dojo that a colleague mentioned after I posted this question that when posting with a C# tag it changes to C++.
I will PM you the ImpersonatedUser Class now to see if there are any errors with them.
Thank you for your response and your time.