I have a couple of powershell command that are very simple.
disable-mailbox dadelgad -confirm:$false
enable-mailbox -identity 'dadelgad' -database 'NET5014DB10' -Alias 'dadelgad'
The first command is to disable an exchange mailbox and the second enables the mailbox. I am logged in as a user who is in the Organization Management group which has full admin priviledges to Exchange but is not a domain admin. If I run these commands directly in Powershell, they work fine but they do not work when called from C#.
I created a very simple windows forms app that has a couple of buttons that invokes these commands from C# code. Running the app as the user with full Exchange right, most commands work with no problem such as get-mailbox -identity ‘dadelgad’. I can set flags in Exchange, add alias emails and do most functions but I cannot disable or enable an account.
Do I need to be a domain admin to do these functions. It almost seems like a permission issue but the user has full rights to Exchange and can perform both of these commands directly in Powershell.
Any help would be appreciated?
I finally figured out what was causing this problem so I am passing the info on to you in case you run into the same problem. I found the solution on serverfault.com at this url. What was happening is the user that I was logged in as and running the program was being blocked by the UAC (User Access Control). Turning it off solved the problem. Well, not really solved as I shouldn’t run wide open like this but told me what the problem was. Now I need to go back and see if I can tweak the permissions to allow the program to run but also provide protection.