public int IndexOf(ActiveDirectorySubnet subnet) { if (subnet != null) { if (subnet.existing) { string propertyValue = (string)PropertyManager.GetPropertyValue(subnet.context, subnet.cachedEntry, PropertyManager.DistinguishedName); int num = 0; while (num < base.InnerList.Count) { ActiveDirectorySubnet item = (ActiveDirectorySubnet)base.InnerList[num]; string str = (string)PropertyManager.GetPropertyValue(item.context, item.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(str, propertyValue) != 0) { num++; } else { return(num); } } return(-1); } else { object[] name = new object[1]; name[0] = subnet.Name; throw new InvalidOperationException(Res.GetString("SubnetNotCommitted", name)); } } else { throw new ArgumentNullException("subnet"); } }
public int Add(ActiveDirectorySubnet subnet) { if (subnet != null) { if (subnet.existing) { if (this.Contains(subnet)) { object[] objArray = new object[1]; objArray[0] = subnet; throw new ArgumentException(Res.GetString("AlreadyExistingInCollection", objArray), "subnet"); } else { return base.List.Add(subnet); } } else { object[] name = new object[1]; name[0] = subnet.Name; throw new InvalidOperationException(Res.GetString("SubnetNotCommitted", name)); } } else { throw new ArgumentNullException("subnet"); } }
public int IndexOf(ActiveDirectorySubnet subnet) { if (subnet == null) { throw new ArgumentNullException("subnet"); } if (!subnet.existing) { throw new InvalidOperationException(Res.GetString(Res.SubnetNotCommitted, subnet.Name)); } string dn = (string)PropertyManager.GetPropertyValue(subnet.context, subnet.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySubnet tmp = (ActiveDirectorySubnet)InnerList[i]; string tmpDn = (string)PropertyManager.GetPropertyValue(tmp.context, tmp.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(tmpDn, dn) == 0) { return(i); } } return(-1); }
public int Add(ActiveDirectorySubnet subnet) { if (subnet != null) { if (subnet.existing) { if (this.Contains(subnet)) { object[] objArray = new object[1]; objArray[0] = subnet; throw new ArgumentException(Res.GetString("AlreadyExistingInCollection", objArray), "subnet"); } else { return(base.List.Add(subnet)); } } else { object[] name = new object[1]; name[0] = subnet.Name; throw new InvalidOperationException(Res.GetString("SubnetNotCommitted", name)); } } else { throw new ArgumentNullException("subnet"); } }
public bool Contains(ActiveDirectorySubnet subnet) { if (subnet == null) { throw new ArgumentNullException("subnet"); } if (!subnet.existing) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.SubnetNotCommitted, subnet.Name)); } string dn = (string)PropertyManager.GetPropertyValue(subnet.context, subnet.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySubnet tmp = (ActiveDirectorySubnet)InnerList[i]; string tmpDn = (string)PropertyManager.GetPropertyValue(tmp.context, tmp.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(tmpDn, dn) == 0) { return(true); } } return(false); }
public void Remove(ActiveDirectorySubnet subnet) { if (subnet == null) { throw new ArgumentNullException("subnet"); } if (!subnet.existing) { throw new InvalidOperationException(Res.GetString(Res.SubnetNotCommitted, subnet.Name)); } string dn = (string)PropertyManager.GetPropertyValue(subnet.context, subnet.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySubnet tmp = (ActiveDirectorySubnet)InnerList[i]; string tmpDn = (string)PropertyManager.GetPropertyValue(tmp.context, tmp.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(tmpDn, dn) == 0) { List.Remove(tmp); return; } } // something that does not exist in the collectio throw new ArgumentException(Res.GetString(Res.NotFoundInCollection, subnet), "subnet"); }
protected override void OnInsertComplete(int index, object value) { if (initialized) { ActiveDirectorySubnet subnet = (ActiveDirectorySubnet)value; string dn = (string)PropertyManager.GetPropertyValue(subnet.context, subnet.cachedEntry, PropertyManager.DistinguishedName); try { if (changeList.Contains(dn)) { ((DirectoryEntry)changeList[dn]).Properties["siteObject"].Value = _siteDN; } else { DirectoryEntry de = DirectoryEntryManager.GetDirectoryEntry(_context, MakePath(dn)); de.Properties["siteObject"].Value = _siteDN; changeList.Add(dn, de); } } catch (COMException e) { throw ExceptionHelper.GetExceptionFromCOMException(_context, e); } } }
public ActiveDirectorySubnet(DirectoryContext context, string subnetName) { ActiveDirectorySubnet.ValidateArgument(context, subnetName); context = new DirectoryContext(context); this.context = context; this.name = subnetName; DirectoryEntry directoryEntry = null; using (directoryEntry) { try { directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext); string str = string.Concat("CN=Subnets,CN=Sites,", propertyValue); directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, str); string escapedPath = string.Concat("cn=", this.name); escapedPath = Utils.GetEscapedPath(escapedPath); this.cachedEntry = directoryEntry.Children.Add(escapedPath, "subnet"); } catch (COMException cOMException1) { COMException cOMException = cOMException1; ExceptionHelper.GetExceptionFromCOMException(context, cOMException); } catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException) { object[] name = new object[1]; name[0] = context.Name; throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", name)); } } }
public ActiveDirectorySubnet this[int index] { get { return((ActiveDirectorySubnet)InnerList[index]); } set { ActiveDirectorySubnet subnet = (ActiveDirectorySubnet)value; if (subnet == null) { throw new ArgumentNullException("value"); } if (!subnet.existing) { throw new InvalidOperationException(Res.GetString(Res.SubnetNotCommitted, subnet.Name)); } if (!Contains(subnet)) { List[index] = subnet; } else { throw new ArgumentException(Res.GetString(Res.AlreadyExistingInCollection, subnet), "value"); } } }
protected override void OnInsertComplete(int index, object value) { if (this.initialized) { ActiveDirectorySubnet subnet = (ActiveDirectorySubnet)value; string key = (string)PropertyManager.GetPropertyValue(subnet.context, subnet.cachedEntry, PropertyManager.DistinguishedName); try { if (this.changeList.Contains(key)) { ((DirectoryEntry)this.changeList[key]).Properties["siteObject"].Value = this.siteDN; } else { DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, this.MakePath(key)); directoryEntry.Properties["siteObject"].Value = this.siteDN; this.changeList.Add(key, directoryEntry); } } catch (COMException exception) { throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception); } } }
public void AddRange(ActiveDirectorySubnet[] subnets) { if (subnets != null) { ActiveDirectorySubnet[] activeDirectorySubnetArray = subnets; int num = 0; while (num < (int)activeDirectorySubnetArray.Length) { ActiveDirectorySubnet activeDirectorySubnet = activeDirectorySubnetArray[num]; if (activeDirectorySubnet != null) { num++; } else { throw new ArgumentException("subnets"); } } for (int i = 0; i < (int)subnets.Length; i++) { this.Add(subnets[i]); } return; } else { throw new ArgumentNullException("subnets"); } }
public int IndexOf(ActiveDirectorySubnet subnet) { Contract.Requires(subnet != null); Contract.Ensures(Contract.Result<int>() >= -1); Contract.Ensures(Contract.Result<int>() < this.Count); return default(int); }
public int IndexOf(ActiveDirectorySubnet subnet) { Contract.Requires(subnet != null); Contract.Ensures(Contract.Result <int>() >= -1); Contract.Ensures(Contract.Result <int>() < this.Count); return(default(int)); }
public int Add(ActiveDirectorySubnet subnet) { if (subnet == null) throw new ArgumentNullException("subnet"); if (!subnet.existing) throw new InvalidOperationException(Res.GetString(Res.SubnetNotCommitted, subnet.Name)); if (!Contains(subnet)) return List.Add(subnet); else throw new ArgumentException(Res.GetString(Res.AlreadyExistingInCollection, subnet), "subnet"); }
public int Add(ActiveDirectorySubnet subnet) { if (subnet == null) { throw new ArgumentNullException("subnet"); } if (!subnet.existing) { throw new InvalidOperationException(Res.GetString("SubnetNotCommitted", new object[] { subnet.Name })); } if (this.Contains(subnet)) { throw new ArgumentException(Res.GetString("AlreadyExistingInCollection", new object[] { subnet }), "subnet"); } return base.List.Add(subnet); }
public int Add(ActiveDirectorySubnet subnet) { if (subnet == null) { throw new ArgumentNullException("subnet"); } if (!subnet.existing) { throw new InvalidOperationException(Res.GetString("SubnetNotCommitted", new object[] { subnet.Name })); } if (this.Contains(subnet)) { throw new ArgumentException(Res.GetString("AlreadyExistingInCollection", new object[] { subnet }), "subnet"); } return(base.List.Add(subnet)); }
public void AddRange(ActiveDirectorySubnet[] subnets) { if (subnets == null) throw new ArgumentNullException("subnets"); foreach (ActiveDirectorySubnet s in subnets) { if (s == null) { throw new ArgumentException("subnets"); } } for (int i = 0; ((i) < (subnets.Length)); i = ((i) + (1))) this.Add(subnets[i]); }
public void AddRange(ActiveDirectorySubnet[] subnets) { if (subnets == null) { throw new ArgumentNullException("subnets"); } ActiveDirectorySubnet[] subnetArray = subnets; for (int i = 0; i < subnetArray.Length; i++) { if (subnetArray[i] == null) { throw new ArgumentException("subnets"); } } for (int j = 0; j < subnets.Length; j++) { this.Add(subnets[j]); } }
public int Add(ActiveDirectorySubnet subnet) { if (subnet == null) { throw new ArgumentNullException("subnet"); } if (!subnet.existing) { throw new InvalidOperationException(Res.GetString(Res.SubnetNotCommitted, subnet.Name)); } if (!Contains(subnet)) { return(List.Add(subnet)); } else { throw new ArgumentException(Res.GetString(Res.AlreadyExistingInCollection, subnet), "subnet"); } }
public void Insert(int index, ActiveDirectorySubnet subnet) { if (subnet == null) { throw new ArgumentNullException("subnet"); } if (!subnet.existing) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.SubnetNotCommitted, subnet.Name)); } if (!Contains(subnet)) { List.Insert(index, subnet); } else { throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, SR.AlreadyExistingInCollection, subnet), "subnet"); } }
public bool Contains(ActiveDirectorySubnet subnet) { if (subnet == null) { throw new ArgumentNullException("subnet"); } if (!subnet.existing) { throw new InvalidOperationException(Res.GetString("SubnetNotCommitted", new object[] { subnet.Name })); } string str = (string) PropertyManager.GetPropertyValue(subnet.context, subnet.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < base.InnerList.Count; i++) { ActiveDirectorySubnet subnet2 = (ActiveDirectorySubnet) base.InnerList[i]; string str2 = (string) PropertyManager.GetPropertyValue(subnet2.context, subnet2.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(str2, str) == 0) { return true; } } return false; }
public ActiveDirectorySubnet this[int index] { get { return((ActiveDirectorySubnet)base.InnerList[index]); } set { ActiveDirectorySubnet activeDirectorySubnet = value; if (activeDirectorySubnet != null) { if (activeDirectorySubnet.existing) { if (this.Contains(activeDirectorySubnet)) { object[] objArray = new object[1]; objArray[0] = activeDirectorySubnet; throw new ArgumentException(Res.GetString("AlreadyExistingInCollection", objArray), "value"); } else { base.List[index] = activeDirectorySubnet; return; } } else { object[] name = new object[1]; name[0] = activeDirectorySubnet.Name; throw new InvalidOperationException(Res.GetString("SubnetNotCommitted", name)); } } else { throw new ArgumentNullException("value"); } } }
public bool Contains(ActiveDirectorySubnet subnet) { if (subnet == null) { throw new ArgumentNullException("subnet"); } if (!subnet.existing) { throw new InvalidOperationException(Res.GetString("SubnetNotCommitted", new object[] { subnet.Name })); } string str = (string)PropertyManager.GetPropertyValue(subnet.context, subnet.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < base.InnerList.Count; i++) { ActiveDirectorySubnet subnet2 = (ActiveDirectorySubnet)base.InnerList[i]; string str2 = (string)PropertyManager.GetPropertyValue(subnet2.context, subnet2.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(str2, str) == 0) { return(true); } } return(false); }
public ActiveDirectorySubnet this[int index] { get { return((ActiveDirectorySubnet)base.InnerList[index]); } set { ActiveDirectorySubnet subnet = value; if (subnet == null) { throw new ArgumentNullException("value"); } if (!subnet.existing) { throw new InvalidOperationException(Res.GetString("SubnetNotCommitted", new object[] { subnet.Name })); } if (this.Contains(subnet)) { throw new ArgumentException(Res.GetString("AlreadyExistingInCollection", new object[] { subnet }), "value"); } base.List[index] = subnet; } }
protected override void OnRemoveComplete(int index, object value) { ActiveDirectorySubnet activeDirectorySubnet = (ActiveDirectorySubnet)value; string propertyValue = (string)PropertyManager.GetPropertyValue(activeDirectorySubnet.context, activeDirectorySubnet.cachedEntry, PropertyManager.DistinguishedName); try { if (!this.changeList.Contains(propertyValue)) { DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, this.MakePath(propertyValue)); directoryEntry.Properties["siteObject"].Clear(); this.changeList.Add(propertyValue, directoryEntry); } else { ((DirectoryEntry)this.changeList[propertyValue]).Properties["siteObject"].Clear(); } } catch (COMException cOMException1) { COMException cOMException = cOMException1; throw ExceptionHelper.GetExceptionFromCOMException(this.context, cOMException); } }
public void CopyTo (ActiveDirectorySubnet[] array, int index) { throw new NotImplementedException (); }
public bool Contains(ActiveDirectorySubnet subnet) { if (subnet == null) throw new ArgumentNullException("subnet"); if (!subnet.existing) throw new InvalidOperationException(Res.GetString(Res.SubnetNotCommitted, subnet.Name)); string dn = (string)PropertyManager.GetPropertyValue(subnet.context, subnet.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySubnet tmp = (ActiveDirectorySubnet)InnerList[i]; string tmpDn = (string)PropertyManager.GetPropertyValue(tmp.context, tmp.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(tmpDn, dn) == 0) { return true; } } return false; }
public int IndexOf (ActiveDirectorySubnet subnet) { throw new NotImplementedException (); }
public void CopyTo(ActiveDirectorySubnet[] array, int index) { List.CopyTo(array, index); }
public void Insert (int index, ActiveDirectorySubnet subnet) { throw new NotImplementedException (); }
public bool Contains(ActiveDirectorySubnet subnet) { Contract.Requires(subnet != null); return default(bool); }
public int Add(ActiveDirectorySubnet subnet) { Contract.Requires(subnet != null); return default(int); }
public void Insert(int index, ActiveDirectorySubnet subnet) { throw new NotImplementedException(); }
public int IndexOf(ActiveDirectorySubnet subnet) { throw new NotImplementedException(); }
public bool Contains (ActiveDirectorySubnet subnet) { throw new NotImplementedException (); }
private void GetSubnets() { DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, WellKnownDN.RootDSE); string propertyValue = (string)PropertyManager.GetPropertyValue(this.context, directoryEntry, PropertyManager.ConfigurationNamingContext); string str = string.Concat("CN=Subnets,CN=Sites,", propertyValue); directoryEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, str); string[] strArrays = new string[2]; strArrays[0] = "cn"; strArrays[1] = "location"; ADSearcher aDSearcher = new ADSearcher(directoryEntry, string.Concat("(&(objectClass=subnet)(objectCategory=subnet)(siteObject=", Utils.GetEscapedFilterValue((string)PropertyManager.GetPropertyValue(this.context, this.cachedEntry, PropertyManager.DistinguishedName)), "))"), strArrays, SearchScope.OneLevel); SearchResultCollection searchResultCollections = null; try { searchResultCollections = aDSearcher.FindAll(); } catch (COMException cOMException1) { COMException cOMException = cOMException1; throw ExceptionHelper.GetExceptionFromCOMException(this.context, cOMException); } try { foreach (SearchResult searchResult in searchResultCollections) { string searchResultPropertyValue = (string)PropertyManager.GetSearchResultPropertyValue(searchResult, PropertyManager.Cn); ActiveDirectorySubnet activeDirectorySubnet = new ActiveDirectorySubnet(this.context, searchResultPropertyValue, null, true); activeDirectorySubnet.cachedEntry = searchResult.GetDirectoryEntry(); activeDirectorySubnet.Site = this; this.subnets.Add(activeDirectorySubnet); } } finally { searchResultCollections.Dispose(); directoryEntry.Dispose(); } }
public int IndexOf(ActiveDirectorySubnet subnet) { if (subnet != null) { if (subnet.existing) { string propertyValue = (string)PropertyManager.GetPropertyValue(subnet.context, subnet.cachedEntry, PropertyManager.DistinguishedName); int num = 0; while (num < base.InnerList.Count) { ActiveDirectorySubnet item = (ActiveDirectorySubnet)base.InnerList[num]; string str = (string)PropertyManager.GetPropertyValue(item.context, item.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(str, propertyValue) != 0) { num++; } else { return num; } } return -1; } else { object[] name = new object[1]; name[0] = subnet.Name; throw new InvalidOperationException(Res.GetString("SubnetNotCommitted", name)); } } else { throw new ArgumentNullException("subnet"); } }
private void GetSubnets() { // performs a search to find out the subnets that belong to this site DirectoryEntry de = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string config = (string)PropertyManager.GetPropertyValue(context, de, PropertyManager.ConfigurationNamingContext); string subnetContainer = "CN=Subnets,CN=Sites," + config; de = DirectoryEntryManager.GetDirectoryEntry(context, subnetContainer); ADSearcher adSearcher = new ADSearcher(de, "(&(objectClass=subnet)(objectCategory=subnet)(siteObject=" + Utils.GetEscapedFilterValue((string)PropertyManager.GetPropertyValue(context, cachedEntry, PropertyManager.DistinguishedName)) + "))", new string[] { "cn", "location" }, SearchScope.OneLevel ); SearchResultCollection results = null; try { results = adSearcher.FindAll(); } catch (COMException e) { throw ExceptionHelper.GetExceptionFromCOMException(context, e); } try { string subnetName = null; foreach (SearchResult result in results) { subnetName = (string)PropertyManager.GetSearchResultPropertyValue(result, PropertyManager.Cn); ActiveDirectorySubnet subnet = new ActiveDirectorySubnet(context, subnetName, null, true); // set the cached entry subnet.cachedEntry = result.GetDirectoryEntry(); // set the site info subnet.Site = this; _subnets.Add(subnet); } } finally { results.Dispose(); de.Dispose(); } }
public void Remove(ActiveDirectorySubnet subnet) { throw new NotImplementedException(); }
public void Remove(ActiveDirectorySubnet subnet) { }
public void Insert(int index, ActiveDirectorySubnet subnet) { Contract.Requires(subnet != null); }
public void AddRange(ActiveDirectorySubnet[] subnets) { Contract.Requires(subnets != null); Contract.Requires(Contract.ForAll(subnets, x => x != null)); }
public void CopyTo(ActiveDirectorySubnet[] array, int index) { Contract.Requires(array != null); }
public static ActiveDirectorySubnet FindByName(DirectoryContext context, string subnetName) { DirectoryEntry directoryEntry; ActiveDirectorySubnet subnet2; ValidateArgument(context, subnetName); context = new DirectoryContext(context); try { directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string str = (string) PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext); string dn = "CN=Subnets,CN=Sites," + str; directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, dn); } catch (COMException exception) { throw ExceptionHelper.GetExceptionFromCOMException(context, exception); } catch (ActiveDirectoryObjectNotFoundException) { throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { context.Name })); } try { SearchResult result = new ADSearcher(directoryEntry, "(&(objectClass=subnet)(objectCategory=subnet)(name=" + Utils.GetEscapedFilterValue(subnetName) + "))", new string[] { "distinguishedName" }, SearchScope.OneLevel, false, false).FindOne(); if (result == null) { Exception exception2 = new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySubnet), subnetName); throw exception2; } string siteName = null; DirectoryEntry entry2 = result.GetDirectoryEntry(); if (entry2.Properties.Contains("siteObject")) { NativeComInterfaces.IAdsPathname pathname = (NativeComInterfaces.IAdsPathname) new NativeComInterfaces.Pathname(); pathname.EscapedMode = 4; string bstrADsPath = (string) entry2.Properties["siteObject"][0]; pathname.Set(bstrADsPath, 4); siteName = pathname.Retrieve(11).Substring(3); } ActiveDirectorySubnet subnet = null; if (siteName == null) { subnet = new ActiveDirectorySubnet(context, subnetName, null, true); } else { subnet = new ActiveDirectorySubnet(context, subnetName, siteName, true); } subnet.cachedEntry = entry2; subnet2 = subnet; } catch (COMException exception3) { if (exception3.ErrorCode == -2147016656) { throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySubnet), subnetName); } throw ExceptionHelper.GetExceptionFromCOMException(context, exception3); } finally { if (directoryEntry != null) { directoryEntry.Dispose(); } } return subnet2; }
public void Remove(ActiveDirectorySubnet subnet) { if (subnet == null) throw new ArgumentNullException("subnet"); if (!subnet.existing) throw new InvalidOperationException(Res.GetString(Res.SubnetNotCommitted, subnet.Name)); string dn = (string)PropertyManager.GetPropertyValue(subnet.context, subnet.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySubnet tmp = (ActiveDirectorySubnet)InnerList[i]; string tmpDn = (string)PropertyManager.GetPropertyValue(tmp.context, tmp.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(tmpDn, dn) == 0) { List.Remove(tmp); return; } } // something that does not exist in the collectio throw new ArgumentException(Res.GetString(Res.NotFoundInCollection, subnet), "subnet"); }
public bool Contains(ActiveDirectorySubnet subnet) { Contract.Requires(subnet != null); return(default(bool)); }
public int Add(ActiveDirectorySubnet subnet) { Contract.Requires(subnet != null); return(default(int)); }
public void Remove (ActiveDirectorySubnet subnet) { throw new NotImplementedException (); }
public static void CreateSubnetPlus(string subNetName, string subNetLocation, string siteName, string siteDescription) { // create a new subnet wiht a description try { DirectoryContext forestContext = new DirectoryContext(DirectoryContextType.Forest); // get a site. The subnet will be assigned to it later. ActiveDirectorySite site = ActiveDirectorySite.FindByName(forestContext,siteName); // get a subnet using the specified directory context // and an IP with length of network mask written as: x.x.x.x/x // e.g., 10.1.1.0/24) ActiveDirectorySubnet subnet = new ActiveDirectorySubnet(forestContext,subNetName); // set the location of this subnet subnet.Location = subNetLocation; // set the site to which this subnet is a member subnet.Site = site; // save the subnet to the directory subnet.Save(); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\nSubnet \"{0}\" was created successfully", subnet); // Restore the original foreground and background colors. Console.ResetColor(); // get the subnet from the directory DirectoryEntry de = subnet.GetDirectoryEntry(); // set the description. Currently, this is not exposed as a property of the // ActiveDirectorySubnet object. //de.Properties["description"].Value = subNetLocation + " (" + subNetName + ") in " + siteName; de.Properties["description"].Value = siteDescription; // save the change back to the directory de.CommitChanges(); } catch (ActiveDirectoryOperationException e) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e.Message); Console.ResetColor(); return; } catch (Exception e) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Unexpected exception: {0}\n{1}",e.GetType().Name, e.Message); Console.ResetColor(); } }
public static ActiveDirectorySubnet FindByName(DirectoryContext context, string subnetName) { DirectoryEntry directoryEntry; ActiveDirectorySubnet activeDirectorySubnet; ActiveDirectorySubnet activeDirectorySubnet1; ActiveDirectorySubnet.ValidateArgument(context, subnetName); context = new DirectoryContext(context); try { directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext); string str = string.Concat("CN=Subnets,CN=Sites,", propertyValue); directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, str); } catch (COMException cOMException1) { COMException cOMException = cOMException1; throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException); } catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException) { object[] name = new object[1]; name[0] = context.Name; throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", name)); } using (directoryEntry) { try { string[] strArrays = new string[1]; strArrays[0] = "distinguishedName"; ADSearcher aDSearcher = new ADSearcher(directoryEntry, string.Concat("(&(objectClass=subnet)(objectCategory=subnet)(name=", Utils.GetEscapedFilterValue(subnetName), "))"), strArrays, SearchScope.OneLevel, false, false); SearchResult searchResult = aDSearcher.FindOne(); if (searchResult != null) { string str1 = null; DirectoryEntry directoryEntry1 = searchResult.GetDirectoryEntry(); if (directoryEntry1.Properties.Contains("siteObject")) { NativeComInterfaces.IAdsPathname pathname = (NativeComInterfaces.IAdsPathname)(new NativeComInterfaces.Pathname()); pathname.EscapedMode = 4; string item = (string)directoryEntry1.Properties["siteObject"][0]; pathname.Set(item, 4); string str2 = pathname.Retrieve(11); str1 = str2.Substring(3); } if (str1 != null) { activeDirectorySubnet = new ActiveDirectorySubnet(context, subnetName, str1, true); } else { activeDirectorySubnet = new ActiveDirectorySubnet(context, subnetName, null, true); } activeDirectorySubnet.cachedEntry = directoryEntry1; activeDirectorySubnet1 = activeDirectorySubnet; } else { Exception exception = new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySubnet), subnetName); throw exception; } } catch (COMException cOMException3) { COMException cOMException2 = cOMException3; if (cOMException2.ErrorCode != -2147016656) { throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException2); } else { throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySubnet), subnetName); } } } return(activeDirectorySubnet1); }
public static ActiveDirectorySubnet FindByName(DirectoryContext context, string subnetName) { DirectoryEntry directoryEntry; ActiveDirectorySubnet activeDirectorySubnet; ActiveDirectorySubnet activeDirectorySubnet1; ActiveDirectorySubnet.ValidateArgument(context, subnetName); context = new DirectoryContext(context); try { directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext); string str = string.Concat("CN=Subnets,CN=Sites,", propertyValue); directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, str); } catch (COMException cOMException1) { COMException cOMException = cOMException1; throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException); } catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException) { object[] name = new object[1]; name[0] = context.Name; throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", name)); } using (directoryEntry) { try { string[] strArrays = new string[1]; strArrays[0] = "distinguishedName"; ADSearcher aDSearcher = new ADSearcher(directoryEntry, string.Concat("(&(objectClass=subnet)(objectCategory=subnet)(name=", Utils.GetEscapedFilterValue(subnetName), "))"), strArrays, SearchScope.OneLevel, false, false); SearchResult searchResult = aDSearcher.FindOne(); if (searchResult != null) { string str1 = null; DirectoryEntry directoryEntry1 = searchResult.GetDirectoryEntry(); if (directoryEntry1.Properties.Contains("siteObject")) { NativeComInterfaces.IAdsPathname pathname = (NativeComInterfaces.IAdsPathname)(new NativeComInterfaces.Pathname()); pathname.EscapedMode = 4; string item = (string)directoryEntry1.Properties["siteObject"][0]; pathname.Set(item, 4); string str2 = pathname.Retrieve(11); str1 = str2.Substring(3); } if (str1 != null) { activeDirectorySubnet = new ActiveDirectorySubnet(context, subnetName, str1, true); } else { activeDirectorySubnet = new ActiveDirectorySubnet(context, subnetName, null, true); } activeDirectorySubnet.cachedEntry = directoryEntry1; activeDirectorySubnet1 = activeDirectorySubnet; } else { Exception exception = new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySubnet), subnetName); throw exception; } } catch (COMException cOMException3) { COMException cOMException2 = cOMException3; if (cOMException2.ErrorCode != -2147016656) { throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException2); } else { throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySubnet), subnetName); } } } return activeDirectorySubnet1; }
public void Remove(ActiveDirectorySubnet subnet) { if (subnet != null) { if (subnet.existing) { string propertyValue = (string)PropertyManager.GetPropertyValue(subnet.context, subnet.cachedEntry, PropertyManager.DistinguishedName); int num = 0; while (num < base.InnerList.Count) { ActiveDirectorySubnet item = (ActiveDirectorySubnet)base.InnerList[num]; string str = (string)PropertyManager.GetPropertyValue(item.context, item.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(str, propertyValue) != 0) { num++; } else { base.List.Remove(item); return; } } object[] objArray = new object[1]; objArray[0] = subnet; throw new ArgumentException(Res.GetString("NotFoundInCollection", objArray), "subnet"); } else { object[] name = new object[1]; name[0] = subnet.Name; throw new InvalidOperationException(Res.GetString("SubnetNotCommitted", name)); } } else { throw new ArgumentNullException("subnet"); } }
public static ActiveDirectorySubnet FindByName(DirectoryContext context, string subnetName) { DirectoryEntry directoryEntry; ActiveDirectorySubnet subnet2; ValidateArgument(context, subnetName); context = new DirectoryContext(context); try { directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string str = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext); string dn = "CN=Subnets,CN=Sites," + str; directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, dn); } catch (COMException exception) { throw ExceptionHelper.GetExceptionFromCOMException(context, exception); } catch (ActiveDirectoryObjectNotFoundException) { throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { context.Name })); } try { SearchResult result = new ADSearcher(directoryEntry, "(&(objectClass=subnet)(objectCategory=subnet)(name=" + Utils.GetEscapedFilterValue(subnetName) + "))", new string[] { "distinguishedName" }, SearchScope.OneLevel, false, false).FindOne(); if (result == null) { Exception exception2 = new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySubnet), subnetName); throw exception2; } string siteName = null; DirectoryEntry entry2 = result.GetDirectoryEntry(); if (entry2.Properties.Contains("siteObject")) { NativeComInterfaces.IAdsPathname pathname = (NativeComInterfaces.IAdsPathname) new NativeComInterfaces.Pathname(); pathname.EscapedMode = 4; string bstrADsPath = (string)entry2.Properties["siteObject"][0]; pathname.Set(bstrADsPath, 4); siteName = pathname.Retrieve(11).Substring(3); } ActiveDirectorySubnet subnet = null; if (siteName == null) { subnet = new ActiveDirectorySubnet(context, subnetName, null, true); } else { subnet = new ActiveDirectorySubnet(context, subnetName, siteName, true); } subnet.cachedEntry = entry2; subnet2 = subnet; } catch (COMException exception3) { if (exception3.ErrorCode == -2147016656) { throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySubnet), subnetName); } throw ExceptionHelper.GetExceptionFromCOMException(context, exception3); } finally { if (directoryEntry != null) { directoryEntry.Dispose(); } } return(subnet2); }
public bool Contains(ActiveDirectorySubnet subnet) { throw new NotImplementedException(); }
public static ActiveDirectorySubnet FindByName(DirectoryContext context, string subnetName) { ValidateArgument(context, subnetName); // work with copy of the context context = new DirectoryContext(context); // bind to the rootdse to get the configurationnamingcontext DirectoryEntry de; try { de = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string config = (string)PropertyManager.GetPropertyValue(context, de, PropertyManager.ConfigurationNamingContext); string subnetdn = "CN=Subnets,CN=Sites," + config; de = DirectoryEntryManager.GetDirectoryEntry(context, subnetdn); } catch (COMException e) { throw ExceptionHelper.GetExceptionFromCOMException(context, e); } catch (ActiveDirectoryObjectNotFoundException) { // this is the case where the context is a config set and we could not find an ADAM instance in that config set throw new ActiveDirectoryOperationException(Res.GetString(Res.ADAMInstanceNotFoundInConfigSet, context.Name)); } try { ADSearcher adSearcher = new ADSearcher(de, "(&(objectClass=subnet)(objectCategory=subnet)(name=" + Utils.GetEscapedFilterValue(subnetName) + "))", new string[] { "distinguishedName" }, SearchScope.OneLevel, false, /* don't need paged search */ false /* don't need to cache result */); SearchResult srchResult = adSearcher.FindOne(); if (srchResult == null) { // no such subnet object Exception e = new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.DSNotFound), typeof(ActiveDirectorySubnet), subnetName); throw e; } else { string siteName = null; DirectoryEntry connectionEntry = srchResult.GetDirectoryEntry(); // try to get the site that this subnet lives in if (connectionEntry.Properties.Contains("siteObject")) { NativeComInterfaces.IAdsPathname pathCracker = (NativeComInterfaces.IAdsPathname) new NativeComInterfaces.Pathname(); // need to turn off the escaping for name pathCracker.EscapedMode = NativeComInterfaces.ADS_ESCAPEDMODE_OFF_EX; string tmp = (string)connectionEntry.Properties["siteObject"][0]; // escaping manipulation pathCracker.Set(tmp, NativeComInterfaces.ADS_SETTYPE_DN); string rdn = pathCracker.Retrieve(NativeComInterfaces.ADS_FORMAT_LEAF); Debug.Assert(rdn != null && Utils.Compare(rdn, 0, 3, "CN=", 0, 3) == 0); siteName = rdn.Substring(3); } // it is an existing subnet object ActiveDirectorySubnet subnet = null; if (siteName == null) { subnet = new ActiveDirectorySubnet(context, subnetName, null, true); } else { subnet = new ActiveDirectorySubnet(context, subnetName, siteName, true); } subnet.cachedEntry = connectionEntry; return(subnet); } } catch (COMException e) { if (e.ErrorCode == unchecked ((int)0x80072030)) { // object is not found since we cannot even find the container in which to search throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.DSNotFound), typeof(ActiveDirectorySubnet), subnetName); } else { throw ExceptionHelper.GetExceptionFromCOMException(context, e); } } finally { if (de != null) { de.Dispose(); } } }
public void AddRange (ActiveDirectorySubnet[] subnets) { throw new NotImplementedException (); }