I have to write a ASP.NET application in C# that returns the mailquota of a exchange mailaccount. The exchange is connected to a active directory and the mailquota is set to default.
I have tried to do this but i cant get the needed fields, someone an idea?
DirectoryContext context = new DirectoryContext(DirectoryContextType.Domain, "FQD");
DomainControllerCollection dcc = DomainController.FindAll(context);
DirectorySearcher dSearch = dcc[0].GetDirectorySearcher();
dSearch.Filter= string.Format("sAMAccountName={0}",model.UserName);
dSearch.PropertiesToLoad.Add("displayName");
dSearch.PropertiesToLoad.Add("mail");
dSearch.PropertiesToLoad.Add("mDBOverHardQuotaLimit");
dSearch.PropertiesToLoad.Add("mDBStorageQuota");
dSearch.PropertiesToLoad.Add("mDBOverQuotaLimit");
dSearch.SizeLimit = 10;
SearchResult sr = dSearch.FindOne();
Not sure I follow. You’re saying the data isn’t returned? If they’re using defaults (there’s an
mdbUseDefaultsor similiar attribute), then you need to walk back to the user’s mailbox database to get their quota. That link is stored in thehomeMdbattribute. You’ll need Exchange View-Only permissions to see those objects, though.