get Mailbox usage using WMI without Admin rights
am 20.11.2007 07:53:21 von garksI am using Exchange 2003(Exchange Hosting), C#.
I am trying to get Mailbox usage using WMI
But I follows the coding below, still cannot get the Mailbox usage.
Even though, I predefined the username and password.
Often gets "Access denied" while running the code.
I have tried to add the user to the \root\MicrosoftExchangeV2, and the
delegate control, but still cannot.
Is there anything I missing to add?
Or other methods that can access the mailbox usage?
Thanks in advanced
System.Management.ConnectionOptions objconn = new
System.Management.ConnectionOptions();
objconn.Impersonation =
System.Management.ImpersonationLevel.Impersonate;
objconn.EnablePrivileges = true;
string cServername = "servername";
System.Management.ManagementScope exmangescope = new
System.Management.ManagementScope(@"\\" + cServername + @"\root
\MicrosoftExchangeV2",objconn);
System.Management.ObjectQuery objquery = new
System.Management.ObjectQuery("SELECT * FROM Exchange_Mailbox");
System.Management.ManagementObjectSearcher objsearch = new
System.Management.ManagementObjectSearcher(exmangescope,objq uery);
System.Management.ManagementObjectCollection queryCollection1 =
objsearch.Get();
string strDisplay;
foreach( System.Management.ManagementObject instmailbox in
queryCollection1 )
{
strDisplay = instmailbox["MailboxDisplayName"].ToString() + " " +
instmailbox["size"].ToString();
System.Console.WriteLine(strDisplay);
}