Click here to Skip to main content
15,924,367 members
Home / Discussions / C#
   

C#

 
QuestionImage from Drawing Pin
Sabry190517-Aug-06 0:44
Sabry190517-Aug-06 0:44 
AnswerRe: Image from Drawing Pin
Christian Graus17-Aug-06 1:00
protectorChristian Graus17-Aug-06 1:00 
Questionbinding data with texboxes Pin
Mamphekgo17-Aug-06 0:31
Mamphekgo17-Aug-06 0:31 
QuestionExpress Edition OR Professional Edition Pin
M Riaz Bashir16-Aug-06 23:59
M Riaz Bashir16-Aug-06 23:59 
AnswerRe: Express Edition OR Professional Edition Pin
Christian Graus17-Aug-06 0:33
protectorChristian Graus17-Aug-06 0:33 
AnswerRe: Express Edition OR Professional Edition Pin
Nader Elshehabi17-Aug-06 1:17
Nader Elshehabi17-Aug-06 1:17 
AnswerRe: Express Edition OR Professional Edition Pin
User 665817-Aug-06 1:48
User 665817-Aug-06 1:48 
QuestionGetting all public folders in Exchange through AD or WMI Pin
killazzz16-Aug-06 23:57
killazzz16-Aug-06 23:57 
Hello,
This is what I'm trying to do.
Get the public folders out of each Exchange Server (that is visible through the Exchange System Manager). As the select * from exchange_PublicFolder only shows the folders at the highest level and not per storage group I looking at the ADSI approach.

this is the code so far. Parts have been commented out as I'm testing this new part with ADSI.
<br />
try<br />
			{<br />
				string cServername;<br />
				ManagementObjectCollection mcExchange=queryServer(".","select * from Exchange_Server");<br />
				txtNoOfServers.Text=mcExchange.Count.ToString();<br />
				//Double ttlSize=0;<br />
				foreach(ManagementObject moExchange in mcExchange)<br />
				{<br />
					cServername = moExchange["Name"].ToString();<br />
				<br />
				<br />
				<br />
					string[] SQLArray=new string[7];<br />
					<br />
					SQLArray[0]="select * from Exchange_Mailbox where size <=10240";<br />
					SQLArray[1]="select * from Exchange_Mailbox where size >" + 10240 + " and size <=" + 5*10240;<br />
					SQLArray[2]="select * from Exchange_Mailbox where size >" + 5*10240 + " and size <=" + 10*10240;<br />
					SQLArray[3]="select * from Exchange_Mailbox where size >" + 10*10240 + " and size <=" + 25*10240;<br />
					SQLArray[4]="select * from Exchange_Mailbox where size >" + 25*10240 + " and size <=" + 50*10240;<br />
					SQLArray[5]="select * from Exchange_Mailbox where size >" + 50*10240 + " and size <=" + 100*10240;<br />
					SQLArray[6]="select * from Exchange_Mailbox where size >" + 100*10240;<br />
					// number of mailboxes<br />
					txtMB.Text=queryServer(cServername,"select * from Exchange_Mailbox").Count.ToString();<br />
					//Mailbox sizes<br />
					int[] MBSizesArray= new int[7];<br />
					lstMBSizes.Items.Add(cServername);<br />
					for (int i=0;i<7;i++)<br />
					{<br />
						MBSizesArray[i]=queryServer(cServername,SQLArray[i]).Count;<br />
						lstMBSizes.Items.Add(MBSizesArray[i].ToString());<br />
					}<br />
					//					//Number of Public folders according to Exchange<br />
					//					txtPF.Text=queryServer(cServername,"select * from Exchange_PublicFolder").Count.ToString();<br />
					//					//PF size<br />
					//					SQLArray[0]="select * from Exchange_PublicFolder where totalmessagesize <=" + 10240;<br />
					//					SQLArray[1]="select * from Exchange_PublicFolder where totalmessagesize >" + 10240 + " and totalmessagesize <=" + 5*10240;<br />
					//					SQLArray[2]="select * from Exchange_PublicFolder where totalmessagesize >" + 5*10240 + " and totalmessagesize <=" + 10*10240;<br />
					//					SQLArray[3]="select * from Exchange_PublicFolder where totalmessagesize >" + 10*10240 + " and totalmessagesize <=" + 25*10240;<br />
					//					SQLArray[4]="select * from Exchange_PublicFolder where totalmessagesize >" + 25*10240 + " and totalmessagesize <=" + 50*10240;<br />
					//					SQLArray[5]="select * from Exchange_PublicFolder where totalmessagesize >" + 50*10240 + " and totalmessagesize <=" + 100*10240;<br />
					//					SQLArray[6]="select * from Exchange_PublicFolder where totalmessagesize >" + 100*10240;<br />
					//					lstPFSizes.Items.Add(cServername);<br />
					//					int[] PFSizesArray= new int[7];<br />
					//					for (int i=0;i<7;i++)<br />
					//					{<br />
					//						PFSizesArray[i]=queryServer(cServername,SQLArray[i]).Count;<br />
					//						lstPFSizes.Items.Add(PFSizesArray[i].ToString());<br />
					//					}<br />
					//number of PF with AD<br />
					DirectoryEntry rootdse=new DirectoryEntry("LDAP://RootDSE");<br />
					DirectoryEntry cfg=new DirectoryEntry("LDAP://"+rootdse.Properties["configurationnamingcontext"].Value);<br />
					DirectorySearcher cfgsearch=new DirectorySearcher(cfg);<br />
					cfgsearch.Filter="(&(objectCategory=msExchExchangeServer)cn="+cServername +")";<br />
					cfgsearch.PropertiesToLoad.Add("distinguishedName");<br />
					cfgsearch.SearchScope=SearchScope.Subtree;<br />
					SearchResult res=cfgsearch.FindOne();<br />
					//define variables<br />
					SearchResultCollection resStorageGroups=searchContainer(res.Properties["distinguishedName"][0].ToString(),"&(objectCategory=msExchStorageGroup)");<br />
					<br />
					//loop through the storagegroup collection<br />
					foreach (SearchResult sg in resStorageGroups)<br />
					{<br />
						SearchResultCollection resMailboxes=searchContainer(sg.Properties["distinguishedName"][0].ToString(),"&(objectCategory=msExchPrivateMDB)");<br />
						//loop through the mailbox collection<br />
						foreach(SearchResult mb in resMailboxes)<br />
						{<br />
<br />
						<br />
						}<br />
					<br />
					}<br />
<br />
<br />
<br />
					//messages to internet<br />
					DateTime startTime=new DateTime(System.DateTime.Now.Year,System.DateTime.Now.Month,System.DateTime.Now.Day-1);<br />
					DateTime endTime=startTime.AddHours(24);<br />
				<br />
					string sTime=startTime.ToString("yyyyMMdd")+ "000000.000000+000";<br />
					string eTime=endTime.ToString("yyyyMMdd")+ "000000.000000+000";<br />
					<br />
				<br />
					ManagementObjectCollection mc=queryServer(cServername,"select * from Exchange_MessageTrackingEntry where Timelogged>='" + sTime + "' and TimeLogged<'" + eTime+"'");<br />
					txtMailVolumeMsg.Text=mc.Count.ToString();<br />
					Double ttlSize=0;<br />
					foreach(ManagementObject mo in mc)<br />
					{<br />
						ttlSize+=Convert.ToDouble(mo["Size"])/(1024*1024);		<br />
					}<br />
					//size to internet<br />
					txtMailVolumeMB.Text=ttlSize.ToString();<br />
				<br />
					//messages from internet<br />
<br />
			<br />
					//size from internet<br />
			<br />
<br />
					//#messages to internal recipient<br />
			<br />
					//size to internal recipient<br />
				}<br />
			}<br />
			catch (Exception ex)<br />
			{<br />
				MessageBox.Show(ex.ToString());<br />
			}<br />
<br />
<br />
		<br />
		}<br />
<br />
		private ManagementObjectCollection queryServer(string servername,string querystring)<br />
		{<br />
			try<br />
			{<br />
				System.Management.ConnectionOptions objconn = new System.Management.ConnectionOptions();<br />
				objconn.Impersonation = System.Management.ImpersonationLevel.Impersonate;<br />
				objconn.EnablePrivileges = true;<br />
				System.Management.ManagementScope exmangescope = new System.Management.ManagementScope(@"\\" + servername + @"\root\MicrosoftExchangeV2",objconn);<br />
				System.Management.ObjectQuery objquery = new System.Management.ObjectQuery(querystring);<br />
				System.Management.ManagementObjectSearcher objsearch = new System.Management.ManagementObjectSearcher(exmangescope,objquery);<br />
				return objsearch.Get();<br />
			}<br />
			catch (Exception e)<br />
			{<br />
				MessageBox.Show(e.ToString());<br />
				return null;<br />
			}<br />
		}<br />
<br />
		private SearchResultCollection searchContainer(string p,string fltr)<br />
		{<br />
			try<br />
			{<br />
				DirectoryEntry serverContainer=new DirectoryEntry("LDAP://"+p);<br />
				DirectorySearcher serverSearch=new DirectorySearcher(serverContainer);<br />
				serverSearch.Filter=fltr;<br />
				serverSearch.SearchScope=SearchScope.Subtree;<br />
				serverSearch.PropertiesToLoad.Add("cn");<br />
				serverSearch.PropertiesToLoad.Add("distinguishedName");<br />
				serverSearch.PropertiesToLoad.Add("homeMDBBL");<br />
				SearchResultCollection result=serverSearch.FindAll();<br />
<br />
				return result;<br />
			}<br />
			catch (Exception srcex)<br />
			{<br />
				MessageBox.Show(srcex.ToString());<br />
			<br />
			}<br />
		}



msExchPrivateMDB is the name to select the mailbox data. I'm sure there must be one for public folders as well ?

Any help would be greatly appreciated.
Questionhelp me Pin
sarojkumarjena16-Aug-06 23:51
sarojkumarjena16-Aug-06 23:51 
AnswerRe: help me [modified] Pin
coolestCoder17-Aug-06 0:00
coolestCoder17-Aug-06 0:00 
QuestionSubscribing to monitor wake-up Pin
royk12316-Aug-06 23:38
royk12316-Aug-06 23:38 
QuestionXmlDataSource vs DataSource Pin
Malcolm Smart16-Aug-06 23:37
Malcolm Smart16-Aug-06 23:37 
AnswerRe: XmlDataSource vs DataSource Pin
hamidreza_buddy17-Aug-06 1:07
hamidreza_buddy17-Aug-06 1:07 
AnswerRe: XmlDataSource vs DataSource Pin
Malcolm Smart17-Aug-06 1:39
Malcolm Smart17-Aug-06 1:39 
QuestionSystem.Net.WebException Pin
Will Manning16-Aug-06 23:16
Will Manning16-Aug-06 23:16 
QuestionConnect to internt using C# Pin
Mridang Agarwalla16-Aug-06 23:16
Mridang Agarwalla16-Aug-06 23:16 
AnswerRe: Connect to internt using C# Pin
Nader Elshehabi17-Aug-06 1:44
Nader Elshehabi17-Aug-06 1:44 
QuestionGenerics: T x = 5 fails [modified] Pin
Tomerland16-Aug-06 22:57
Tomerland16-Aug-06 22:57 
AnswerRe: Generics: T x = 5 fails Pin
Christian Graus16-Aug-06 23:05
protectorChristian Graus16-Aug-06 23:05 
GeneralRe: Generics: T x = 5 fails Pin
Tomerland17-Aug-06 0:30
Tomerland17-Aug-06 0:30 
GeneralRe: Generics: T x = 5 fails Pin
Christian Graus17-Aug-06 0:37
protectorChristian Graus17-Aug-06 0:37 
GeneralRe: Generics: T x = 5 fails [modified] Pin
Tomerland17-Aug-06 1:27
Tomerland17-Aug-06 1:27 
GeneralRe: Generics: T x = 5 fails Pin
Christian Graus17-Aug-06 1:40
protectorChristian Graus17-Aug-06 1:40 
GeneralRe: Generics: T x = 5 fails Pin
Nader Elshehabi17-Aug-06 2:07
Nader Elshehabi17-Aug-06 2:07 
GeneralRe: Generics: T x = 5 fails Pin
Christian Graus17-Aug-06 2:15
protectorChristian Graus17-Aug-06 2:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.