I'm trying to retrieve all the subnets in our AD. I need the values from the cn, location, description and Site attributes. I can see these attributes when i open the "Active Directory Sites and Services" app and select "subnets"
I found some code which i thought would retrieve these values
Forest myForest = Forest.GetCurrentForest();
ReadOnlySiteCollection mySites = default(ReadOnlySiteCollection);
ActiveDirectorySubnetCollection mySubnets = default(ActiveDirectorySubnetCollection);
int iEnumSites = 0;
int iEnumSubnets = 0;
mySites = myForest.Sites;
Dictionary<string, Subnet> Subnets = new Dictionary<string, Subnet>();
//for each site loop through
for (iEnumSites = 0; iEnumSites < mySites.Count -1; iEnumSites++)
{
// for each subnet in each site loop through
mySubnets = mySites[iEnumSites].Subnets;
for (iEnumSubnets = 0 ; iEnumSubnets < mySubnets.Count -1; iEnumSubnets++)
{
Subnet s = new Subnet(mySubnets[iEnumSubnets].Name, mySubnet[iEnumSubnets].Site, mySubnets[iEnumSubnets].Location,"");
Subnets.Add(s.GetKey(), s);
}
}
However, the "Description" attribute isn't there. Each Subnet only exposes 3 properties/attributes. Does anyone know how i can get access to all the Attributes on all our subnets ?
Thanks
Erck