using
System.DirectoryServices.DirectorySearcher mySearcher =
mySearcher.Filter = ("(&(objectClass=user)(samaccountname=*)(mail=*)(homeMDB=*)(homemta=*)(msexchhomeservername=*)(legacyexchangedn=*)(mdbusedefaults=*))");
mySearcher.SizeLimit = 0;
mySearcher.PageSize = 999;
mySearcher.SearchScope = SearchScope.Subtree;
mySearcher.PropertiesToLoad.Add("samaccountname");
mySearcher.PropertiesToLoad.Add("mail");
mySearcher.PropertiesToLoad.Add("mailnickname");
mySearcher.PropertiesToLoad.Add("homemdb");
mySearcher.PropertiesToLoad.Add("homemta");
mySearcher.PropertiesToLoad.Add("msexchhomeservername");
mySearcher.PropertiesToLoad.Add("mdbusedefaults");
mySearcher.PropertiesToLoad.Add("mdbstoragequota");
mySearcher.PropertiesToLoad.Add("mdboverquotalimit");
mySearcher.PropertiesToLoad.Add("mdboverhardquotalimit");
mySearcher.PropertiesToLoad.Add("legacyexchangedn");
mySearcher.PropertiesToLoad.Add("msexchmailboxguid");
w.WriteLine("sAMAccountName,mail,mailNickname,homeMDB,homeMTA,msExchHomeServerName,mDBUseDefaults,mDBStorageQuota,mDBOverQuotaLimit,mDBOverHardQuotaLimit,legacyExchangeDN,msExchMailboxGUID,ADPath");
SearchResultCollection ResEnt = mySearcher.FindAll();
{
qWarn = "N/A";
qLimit = "N/A";
qDeny = "N/A";
AcctName = resEnt1.Properties["samaccountname"][0].ToString();
PrimaryMail = resEnt1.Properties["mail"][0].ToString();
mailnickname = resEnt1.Properties["mailnickname"][0].ToString();
homeMDB = resEnt1.Properties["homemdb"][0].ToString();
homeMTA = resEnt1.Properties["homemta"][0].ToString();
homeServer = resEnt1.Properties["msexchhomeservername"][0].ToString();
qDefaults = resEnt1.Properties["mdbusedefaults"][0].ToString();
qWarn = resEnt1.Properties["mdbstoragequota"][0].ToString();
qLimit = resEnt1.Properties["mdboverquotalimit"][0].ToString();
qDeny = resEnt1.Properties["mdboverhardquotalimit"][0].ToString();
}
legacyDN = resEnt1.Properties["legacyexchangedn"][0].ToString();
MailGUID = (
ObjLoc = resEnt1.Path.ToString();
sMailGUID = HexEncoding.ToString(MailGUID);
w.Write("{0},{1},{2},'{3}','{4}',{5},{6},{7},{8},{9},{10},",AcctName,PrimaryMail,mailnickname,homeMDB,homeMTA,homeServer,qDefaults,qWarn,qLimit,qDeny,legacyDN);
w.Write("{0:x2}",b);
w.WriteLine(",'{0}'",ObjLoc);
}So given that I am searching correctly, if I wanted to modify attributes like homeMDB, could I within the foreach do something like resEnt1.Properties["homeMDB"][0] = "whatever I want it to be"The idea here is that since I have already expended the resources to do the search whose handle is pointed to by the SearchResultCollection, cant I use the collection in someway to manipulate AD property values?Thanks.