public void Remove(ActiveDirectorySite site) { if (site == null) { throw new ArgumentNullException("site"); } if (!site.existing) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.SiteNotCommitted, site.Name)); } string dn = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySite tmp = (ActiveDirectorySite)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(String.Format(CultureInfo.CurrentCulture, SR.NotFoundInCollection, site), "site"); }
public bool Contains(ActiveDirectorySite site) { if (site == null) { throw new ArgumentNullException("site"); } if (!site.existing) { throw new InvalidOperationException(Res.GetString(Res.SiteNotCommitted, site.Name)); } string dn = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySite tmp = (ActiveDirectorySite)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 Add(ActiveDirectorySite site) { if (site != null) { if (site.existing) { if (this.Contains(site)) { object[] objArray = new object[1]; objArray[0] = site; throw new ArgumentException(Res.GetString("AlreadyExistingInCollection", objArray), "site"); } else { return base.List.Add(site); } } else { object[] name = new object[1]; name[0] = site.Name; throw new InvalidOperationException(Res.GetString("SiteNotCommitted", name)); } } else { throw new ArgumentNullException("site"); } }
public ActiveDirectorySubnet(DirectoryContext context, string subnetName, string siteName) : this(context, subnetName) { if (siteName != null) { if (siteName.Length != 0) { try { this.site = ActiveDirectorySite.FindByName(this.context, siteName); } catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException) { object[] objArray = new object[1]; objArray[0] = siteName; throw new ArgumentException(Res.GetString("SiteNotExist", objArray), "siteName"); } return; } else { throw new ArgumentException(Res.GetString("EmptyStringParameter"), "siteName"); } } else { throw new ArgumentNullException("siteName"); } }
public ActiveDirectorySite this[int index] { get { return((ActiveDirectorySite)InnerList[index]); } set { ActiveDirectorySite site = (ActiveDirectorySite)value; if (site == null) { throw new ArgumentNullException("value"); } if (!site.existing) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.SiteNotCommitted, site.Name)); } if (!Contains(site)) { List[index] = site; } else { throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, SR.AlreadyExistingInCollection, site), "value"); } } }
public int Add(ActiveDirectorySite site) { if (site != null) { if (site.existing) { if (this.Contains(site)) { object[] objArray = new object[1]; objArray[0] = site; throw new ArgumentException(Res.GetString("AlreadyExistingInCollection", objArray), "site"); } else { return(base.List.Add(site)); } } else { object[] name = new object[1]; name[0] = site.Name; throw new InvalidOperationException(Res.GetString("SiteNotCommitted", name)); } } else { throw new ArgumentNullException("site"); } }
private void GetSites() { NativeComInterfaces.IAdsPathname pathname = (NativeComInterfaces.IAdsPathname)(new NativeComInterfaces.Pathname()); ArrayList arrayLists = new ArrayList(); pathname.EscapedMode = 4; string str = "siteList"; arrayLists.Add(str); Hashtable valuesWithRangeRetrieval = Utils.GetValuesWithRangeRetrieval(this.cachedEntry, "(objectClass=*)", arrayLists, SearchScope.Base); ArrayList item = (ArrayList)valuesWithRangeRetrieval[str.ToLower(CultureInfo.InvariantCulture)]; if (item != null) { for (int i = 0; i < item.Count; i++) { string item1 = (string)item[i]; pathname.Set(item1, 4); string str1 = pathname.Retrieve(11); str1 = str1.Substring(3); ActiveDirectorySite activeDirectorySite = new ActiveDirectorySite(this.context, str1, true); this.sites.Add(activeDirectorySite); } return; } else { return; } }
public int IndexOf(ActiveDirectorySite site) { if (site != null) { string propertyValue = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); int num = 0; while (num < base.InnerList.Count) { ActiveDirectorySite item = (ActiveDirectorySite)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 { throw new ArgumentNullException("site"); } }
public int IndexOf(ActiveDirectorySite site) { if (site != null) { if (site.existing) { string propertyValue = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); int num = 0; while (num < base.InnerList.Count) { ActiveDirectorySite item = (ActiveDirectorySite)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] = site.Name; throw new InvalidOperationException(Res.GetString("SiteNotCommitted", name)); } } else { throw new ArgumentNullException("site"); } }
public int IndexOf(ActiveDirectorySite site) { if (site == null) { throw new ArgumentNullException("site"); } if (!site.existing) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.SiteNotCommitted, site.Name)); } string dn = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySite tmp = (ActiveDirectorySite)InnerList[i]; string tmpDn = (string)PropertyManager.GetPropertyValue(tmp.context, tmp.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(tmpDn, dn) == 0) { return(i); } } return(-1); }
private void GetSites() { NativeComInterfaces.IAdsPathname pathCracker = null; pathCracker = (NativeComInterfaces.IAdsPathname) new NativeComInterfaces.Pathname(); ArrayList propertyList = new ArrayList(); // need to turn off the escaping for name pathCracker.EscapedMode = NativeComInterfaces.ADS_ESCAPEDMODE_OFF_EX; string propertyName = "siteList"; propertyList.Add(propertyName); Hashtable values = Utils.GetValuesWithRangeRetrieval(cachedEntry, "(objectClass=*)", propertyList, SearchScope.Base); ArrayList siteLists = (ArrayList)values[propertyName.ToLower(CultureInfo.InvariantCulture)]; // somehow no site list if (siteLists == null) { return; } for (int i = 0; i < siteLists.Count; i++) { string dn = (string)siteLists[i]; // escaping manipulation pathCracker.Set(dn, 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); rdn = rdn.Substring(3); ActiveDirectorySite site = new ActiveDirectorySite(context, rdn, true); // add to the collection _sites.Add(site); } }
public int IndexOf(ActiveDirectorySite site) { if (site != null) { string propertyValue = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); int num = 0; while (num < base.InnerList.Count) { ActiveDirectorySite item = (ActiveDirectorySite)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 { throw new ArgumentNullException("site"); } }
public void AddRange(ActiveDirectorySite[] sites) { if (sites == null) throw new ArgumentNullException("sites"); for (int i = 0; ((i) < (sites.Length)); i = ((i) + (1))) this.Add(sites[i]); }
public int IndexOf(ActiveDirectorySite site) { Contract.Requires(site != null); Contract.Ensures(Contract.Result<int>() >= -1); Contract.Ensures(Contract.Result<int>() < this.Count); return default(int); }
public int IndexOf(ActiveDirectorySite site) { Contract.Requires(site != null); Contract.Ensures(Contract.Result <int>() >= -1); Contract.Ensures(Contract.Result <int>() < this.Count); return(default(int)); }
public ADSite(ActiveDirectoryContext Context, ActiveDirectorySite Site) { this.context = Context; this.Site = Site; this.Name = Site.Name; this.DomainControllers = null; }
public void AddRange(ActiveDirectorySite[] sites) { if (sites == null) { throw new ArgumentNullException("sites"); } for (int i = 0; i < sites.Length; i++) { this.Add(sites[i]); } }
public int Add(ActiveDirectorySite site) { if (site == null) throw new ArgumentNullException("site"); if (!site.existing) throw new InvalidOperationException(Res.GetString(Res.SiteNotCommitted, site.Name)); if (!Contains(site)) return List.Add(site); else throw new ArgumentException(Res.GetString(Res.AlreadyExistingInCollection, site), "site"); }
protected override void OnRemoveComplete(int index, object value) { ActiveDirectorySite site = (ActiveDirectorySite)value; string dn = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); try { de.Properties["siteList"].Remove(dn); } catch (COMException e) { throw ExceptionHelper.GetExceptionFromCOMException(context, e); } }
protected override void OnSetComplete(int index, object oldValue, object newValue) { ActiveDirectorySite newsite = (ActiveDirectorySite)newValue; string newdn = (string)PropertyManager.GetPropertyValue(newsite.context, newsite.cachedEntry, PropertyManager.DistinguishedName); try { de.Properties["siteList"][index] = newdn; } catch (COMException e) { throw ExceptionHelper.GetExceptionFromCOMException(context, e); } }
protected override void OnSetComplete(int index, object oldValue, object newValue) { ActiveDirectorySite activeDirectorySite = (ActiveDirectorySite)newValue; string propertyValue = (string)PropertyManager.GetPropertyValue(activeDirectorySite.context, activeDirectorySite.cachedEntry, PropertyManager.DistinguishedName); try { this.de.Properties["siteList"][index] = propertyValue; } catch (COMException cOMException1) { COMException cOMException = cOMException1; throw ExceptionHelper.GetExceptionFromCOMException(this.context, cOMException); } }
public int Add(ActiveDirectorySite site) { if (site == null) { throw new ArgumentNullException("site"); } if (!site.existing) { throw new InvalidOperationException(Res.GetString("SiteNotCommitted", new object[] { site.Name })); } if (this.Contains(site)) { throw new ArgumentException(Res.GetString("AlreadyExistingInCollection", new object[] { site }), "site"); } return base.List.Add(site); }
protected override void OnInsertComplete(int index, object value) { if (this.initialized) { ActiveDirectorySite site = (ActiveDirectorySite)value; string str = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); try { this.de.Properties["siteList"].Add(str); } catch (COMException exception) { throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception); } } }
public int Add(ActiveDirectorySite site) { if (site == null) { throw new ArgumentNullException("site"); } if (!site.existing) { throw new InvalidOperationException(Res.GetString("SiteNotCommitted", new object[] { site.Name })); } if (this.Contains(site)) { throw new ArgumentException(Res.GetString("AlreadyExistingInCollection", new object[] { site }), "site"); } return(base.List.Add(site)); }
internal ActiveDirectorySubnet(DirectoryContext context, string subnetName, string siteName, bool existing) { this.context = context; this.name = subnetName; if (siteName != null) { try { this.site = ActiveDirectorySite.FindByName(context, siteName); } catch (ActiveDirectoryObjectNotFoundException) { throw new ArgumentException(Res.GetString("SiteNotExist", new object[] { siteName }), "siteName"); } } this.existing = true; }
internal ActiveDirectorySubnet(DirectoryContext context, string subnetName, string siteName, bool existing) { this.context = context; this.name = subnetName; if (siteName != null) { try { this.site = ActiveDirectorySite.FindByName(context, siteName); } catch (ActiveDirectoryObjectNotFoundException) { throw new ArgumentException(Res.GetString("SiteNotExist", new object[] { siteName }), "siteName"); } } this.existing = true; }
public int IndexOf(ActiveDirectorySite site) { if (site == null) { throw new ArgumentNullException("site"); } string str = (string) PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < base.InnerList.Count; i++) { ActiveDirectorySite site2 = (ActiveDirectorySite) base.InnerList[i]; string str2 = (string) PropertyManager.GetPropertyValue(site2.context, site2.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(str2, str) == 0) { return i; } } return -1; }
public int IndexOf(ActiveDirectorySite site) { if (site == null) { throw new ArgumentNullException("site"); } string str = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < base.InnerList.Count; i++) { ActiveDirectorySite site2 = (ActiveDirectorySite)base.InnerList[i]; string str2 = (string)PropertyManager.GetPropertyValue(site2.context, site2.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(str2, str) == 0) { return(i); } } return(-1); }
public ActiveDirectorySubnet(DirectoryContext context, string subnetName, string siteName) : this(context, subnetName) { if (siteName == null) { throw new ArgumentNullException("siteName"); } if (siteName.Length == 0) { throw new ArgumentException(Res.GetString("EmptyStringParameter"), "siteName"); } try { this.site = ActiveDirectorySite.FindByName(this.context, siteName); } catch (ActiveDirectoryObjectNotFoundException) { throw new ArgumentException(Res.GetString("SiteNotExist", new object[] { siteName }), "siteName"); } }
public ActiveDirectorySubnet(DirectoryContext context, string subnetName, string siteName) : this(context, subnetName) { if (siteName == null) { throw new ArgumentNullException("siteName"); } if (siteName.Length == 0) { throw new ArgumentException(Res.GetString("EmptyStringParameter"), "siteName"); } try { this.site = ActiveDirectorySite.FindByName(this.context, siteName); } catch (ActiveDirectoryObjectNotFoundException) { throw new ArgumentException(Res.GetString("SiteNotExist", new object[] { siteName }), "siteName"); } }
public int IndexOf(ActiveDirectorySite site) { if (site == null) throw new ArgumentNullException("site"); string dn = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySite tmp = (ActiveDirectorySite)InnerList[i]; string tmpDn = (string)PropertyManager.GetPropertyValue(tmp.context, tmp.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(tmpDn, dn) == 0) { return i; } } return -1; }
internal ActiveDirectorySubnet(DirectoryContext context, string subnetName, string siteName, bool existing) { Debug.Assert(existing == true); this.context = context; _name = subnetName; if (siteName != null) { try { _site = ActiveDirectorySite.FindByName(context, siteName); } catch (ActiveDirectoryObjectNotFoundException) { throw new ArgumentException(Res.GetString(Res.SiteNotExist, siteName), "siteName"); } } this.existing = true; }
public void Insert(int index, ActiveDirectorySite site) { if (site == null) { throw new ArgumentNullException("site"); } if (!site.existing) { throw new InvalidOperationException(Res.GetString(Res.SiteNotCommitted, site.Name)); } if (!Contains(site)) { List.Insert(index, site); } else { throw new ArgumentException(Res.GetString(Res.AlreadyExistingInCollection, site), "site"); } }
public int Add(ActiveDirectorySite site) { if (site == null) { throw new ArgumentNullException("site"); } if (!site.existing) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.SiteNotCommitted, site.Name)); } if (!Contains(site)) { return(List.Add(site)); } else { throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, SR.AlreadyExistingInCollection, site), "site"); } }
public int IndexOf(ActiveDirectorySite site) { if (site == null) { throw new ArgumentNullException(nameof(site)); } string dn = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySite tmp = (ActiveDirectorySite)InnerList[i]; string tmpDn = (string)PropertyManager.GetPropertyValue(tmp.context, tmp.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(tmpDn, dn) == 0) { return(i); } } return(-1); }
public bool Contains(ActiveDirectorySite site) { if (site == null) { throw new ArgumentNullException("site"); } if (!site.existing) { throw new InvalidOperationException(Res.GetString("SiteNotCommitted", new object[] { site.Name })); } string str = (string) PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < base.InnerList.Count; i++) { ActiveDirectorySite site2 = (ActiveDirectorySite) base.InnerList[i]; string str2 = (string) PropertyManager.GetPropertyValue(site2.context, site2.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(str2, str) == 0) { return true; } } return false; }
public bool Contains(ActiveDirectorySite site) { if (site == null) throw new ArgumentNullException("site"); if (!site.existing) throw new InvalidOperationException(Res.GetString(Res.SiteNotCommitted, site.Name)); string dn = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySite tmp = (ActiveDirectorySite)InnerList[i]; string tmpDn = (string)PropertyManager.GetPropertyValue(tmp.context, tmp.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(tmpDn, dn) == 0) { return true; } } return false; }
public ActiveDirectorySubnet(DirectoryContext context, string subnetName, string siteName) : this(context, subnetName) { if (siteName == null) { throw new ArgumentNullException("siteName"); } if (siteName.Length == 0) { throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "siteName"); } // validate that siteName is valid try { _site = ActiveDirectorySite.FindByName(this.context, siteName); } catch (ActiveDirectoryObjectNotFoundException) { throw new ArgumentException(Res.GetString(Res.SiteNotExist, siteName), "siteName"); } }
public ActiveDirectorySite this[int index] { get { return((ActiveDirectorySite)base.InnerList[index]); } set { ActiveDirectorySite activeDirectorySite = value; if (activeDirectorySite != null) { if (activeDirectorySite.existing) { if (this.Contains(activeDirectorySite)) { object[] objArray = new object[1]; objArray[0] = activeDirectorySite; throw new ArgumentException(Res.GetString("AlreadyExistingInCollection", objArray), "value"); } else { base.List[index] = activeDirectorySite; return; } } else { object[] name = new object[1]; name[0] = activeDirectorySite.Name; throw new InvalidOperationException(Res.GetString("SiteNotCommitted", name)); } } else { throw new ArgumentNullException("value"); } } }
public int IndexOf(ActiveDirectorySite site) { if (site == null) { throw new ArgumentNullException("site"); } if (!site.existing) { throw new InvalidOperationException(Res.GetString("SiteNotCommitted", new object[] { site.Name })); } string str = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < base.InnerList.Count; i++) { ActiveDirectorySite site2 = (ActiveDirectorySite)base.InnerList[i]; string str2 = (string)PropertyManager.GetPropertyValue(site2.context, site2.cachedEntry, PropertyManager.DistinguishedName); if (Utils.Compare(str2, str) == 0) { return(i); } } return(-1); }
public ActiveDirectorySite this[int index] { get { return((ActiveDirectorySite)base.InnerList[index]); } set { ActiveDirectorySite site = value; if (site == null) { throw new ArgumentNullException("value"); } if (!site.existing) { throw new InvalidOperationException(Res.GetString("SiteNotCommitted", new object[] { site.Name })); } if (this.Contains(site)) { throw new ArgumentException(Res.GetString("AlreadyExistingInCollection", new object[] { site }), "value"); } base.List[index] = site; } }
private void GetSites() { NativeComInterfaces.IAdsPathname pathname = null; pathname = (NativeComInterfaces.IAdsPathname) new NativeComInterfaces.Pathname(); ArrayList propertiesToLoad = new ArrayList(); pathname.EscapedMode = 4; string str = "siteList"; propertiesToLoad.Add(str); ArrayList list2 = (ArrayList)Utils.GetValuesWithRangeRetrieval(this.cachedEntry, "(objectClass=*)", propertiesToLoad, 0)[str.ToLower(CultureInfo.InvariantCulture)]; if (list2 != null) { for (int i = 0; i < list2.Count; i++) { string bstrADsPath = (string)list2[i]; pathname.Set(bstrADsPath, 4); string siteName = pathname.Retrieve(11).Substring(3); ActiveDirectorySite site = new ActiveDirectorySite(this.context, siteName, true); this.sites.Add(site); } } }
public void CopyTo(ActiveDirectorySite[] sites, int index) { base.InnerList.CopyTo(sites, index); }
public void Remove(ActiveDirectorySite site) { if (site != null) { if (site.existing) { string propertyValue = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); int num = 0; while (num < base.InnerList.Count) { ActiveDirectorySite item = (ActiveDirectorySite)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] = site; throw new ArgumentException(Res.GetString("NotFoundInCollection", objArray), "site"); } else { object[] name = new object[1]; name[0] = site.Name; throw new InvalidOperationException(Res.GetString("SiteNotCommitted", name)); } } else { throw new ArgumentNullException("site"); } }
public int IndexOf(ActiveDirectorySite site) { if (site != null) { if (site.existing) { string propertyValue = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); int num = 0; while (num < base.InnerList.Count) { ActiveDirectorySite item = (ActiveDirectorySite)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] = site.Name; throw new InvalidOperationException(Res.GetString("SiteNotCommitted", name)); } } else { throw new ArgumentNullException("site"); } }
public void CopyTo(ActiveDirectorySite[] array, int index) { base.List.CopyTo(array, index); }
public static ActiveDirectorySite FindByName(DirectoryContext context, string siteName) { DirectoryEntry directoryEntry; ActiveDirectorySite activeDirectorySite; ActiveDirectorySite.ValidateArgument(context, siteName); context = new DirectoryContext(context); try { directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string str = string.Concat("CN=Sites,", (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext)); 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)); } try { try { string[] strArrays = new string[1]; strArrays[0] = "distinguishedName"; ADSearcher aDSearcher = new ADSearcher(directoryEntry, string.Concat("(&(objectClass=site)(objectCategory=site)(name=", Utils.GetEscapedFilterValue(siteName), "))"), strArrays, SearchScope.OneLevel, false, false); SearchResult searchResult = aDSearcher.FindOne(); if (searchResult != null) { ActiveDirectorySite activeDirectorySite1 = new ActiveDirectorySite(context, siteName, true); activeDirectorySite = activeDirectorySite1; } else { throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySite), siteName); } } catch (COMException cOMException3) { COMException cOMException2 = cOMException3; if (cOMException2.ErrorCode != -2147016656) { throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException2); } else { throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySite), siteName); } } } finally { directoryEntry.Dispose(); } return activeDirectorySite; }
public static void CreateAdSite(string siteName) { try { // get a forest context DirectoryContext forestContext = new DirectoryContext( DirectoryContextType.Forest); // create a new site ActiveDirectorySite site = new ActiveDirectorySite(forestContext, siteName); // set site options site.Options = ActiveDirectorySiteOptions.GroupMembershipCachingEnabled; // commit the site to the directory site.Save(); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\nSite \"{0}\" was created successfully", site); Console.ResetColor(); } catch (Exception e) { Console.WriteLine("\r\nUnexpected exception occured:\n\t{0}\n{1}", e.GetType().Name, e.Message); } }
public static void CreateAdamSite(string targetName, string newSiteName) { try { // assemble the connection string using the host name and the port assigned to ADAM string adamConnectionString = targetName; DirectoryContext adamContext = new DirectoryContext( DirectoryContextType.DirectoryServer, adamConnectionString); ActiveDirectorySite site = new ActiveDirectorySite(adamContext, newSiteName); // set site options site.Options = ActiveDirectorySiteOptions.GroupMembershipCachingEnabled; // commit the site to the directory site.Save(); Console.WriteLine("\nSite \"{0}\" was created successfully", site); } catch (Exception e) { Console.WriteLine("\r\nUnexpected exception occured:\n\t{0}\n{1}", e.GetType().Name, e.Message); } }
public int IndexOf(ActiveDirectorySite site) { throw new NotImplementedException(); }
public void CopyTo (ActiveDirectorySite[] sites, int index) { throw new NotImplementedException (); }
private void GetSites() { NativeComInterfaces.IAdsPathname pathname = (NativeComInterfaces.IAdsPathname)(new NativeComInterfaces.Pathname()); ArrayList arrayLists = new ArrayList(); pathname.EscapedMode = 4; string str = "siteList"; arrayLists.Add(str); Hashtable valuesWithRangeRetrieval = Utils.GetValuesWithRangeRetrieval(this.cachedEntry, "(objectClass=*)", arrayLists, SearchScope.Base); ArrayList item = (ArrayList)valuesWithRangeRetrieval[str.ToLower(CultureInfo.InvariantCulture)]; if (item != null) { for (int i = 0; i < item.Count; i++) { string item1 = (string)item[i]; pathname.Set(item1, 4); string str1 = pathname.Retrieve(11); str1 = str1.Substring(3); ActiveDirectorySite activeDirectorySite = new ActiveDirectorySite(this.context, str1, true); this.sites.Add(activeDirectorySite); } return; } else { return; } }
public static ActiveDirectorySite FindByName(DirectoryContext context, string siteName) { // find an existing site ValidateArgument(context, siteName); // work with copy of the context context = new DirectoryContext(context); // bind to the rootdse to get the configurationnamingcontext DirectoryEntry de; string sitedn; try { de = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); sitedn = "CN=Sites," + (string)PropertyManager.GetPropertyValue(context, de, PropertyManager.ConfigurationNamingContext); de = DirectoryEntryManager.GetDirectoryEntry(context, sitedn); } 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=site)(objectCategory=site)(name=" + Utils.GetEscapedFilterValue(siteName) + "))", 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 site object throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.DSNotFound), typeof(ActiveDirectorySite), siteName); } // it is an existing site object ActiveDirectorySite site = new ActiveDirectorySite(context, siteName, true); return site; } 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(ActiveDirectorySite), siteName); } else { throw ExceptionHelper.GetExceptionFromCOMException(context, e); } } finally { de.Dispose(); } }
private void GetSites() { NativeComInterfaces.IAdsPathname pathCracker = null; pathCracker = (NativeComInterfaces.IAdsPathname)new NativeComInterfaces.Pathname(); ArrayList propertyList = new ArrayList(); // need to turn off the escaping for name pathCracker.EscapedMode = NativeComInterfaces.ADS_ESCAPEDMODE_OFF_EX; string propertyName = "siteList"; propertyList.Add(propertyName); Hashtable values = Utils.GetValuesWithRangeRetrieval(cachedEntry, "(objectClass=*)", propertyList, SearchScope.Base); ArrayList siteLists = (ArrayList)values[propertyName.ToLower(CultureInfo.InvariantCulture)]; // somehow no site list if (siteLists == null) return; for (int i = 0; i < siteLists.Count; i++) { string dn = (string)siteLists[i]; // escaping manipulation pathCracker.Set(dn, 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); rdn = rdn.Substring(3); ActiveDirectorySite site = new ActiveDirectorySite(context, rdn, true); // add to the collection _sites.Add(site); } }
public bool Contains (ActiveDirectorySite site) { throw new NotImplementedException (); }
public int IndexOf (ActiveDirectorySite site) { throw new NotImplementedException (); }
public void Remove(ActiveDirectorySite site) { if (site == null) throw new ArgumentNullException("site"); if (!site.existing) throw new InvalidOperationException(Res.GetString(Res.SiteNotCommitted, site.Name)); string dn = (string)PropertyManager.GetPropertyValue(site.context, site.cachedEntry, PropertyManager.DistinguishedName); for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySite tmp = (ActiveDirectorySite)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, site), "site"); }
internal int Add(ActiveDirectorySite site) { return base.InnerList.Add(site); }
private void GetSites() { NativeComInterfaces.IAdsPathname pathname = null; pathname = (NativeComInterfaces.IAdsPathname) new NativeComInterfaces.Pathname(); ArrayList propertiesToLoad = new ArrayList(); pathname.EscapedMode = 4; string str = "siteList"; propertiesToLoad.Add(str); ArrayList list2 = (ArrayList) Utils.GetValuesWithRangeRetrieval(this.cachedEntry, "(objectClass=*)", propertiesToLoad, 0)[str.ToLower(CultureInfo.InvariantCulture)]; if (list2 != null) { for (int i = 0; i < list2.Count; i++) { string bstrADsPath = (string) list2[i]; pathname.Set(bstrADsPath, 4); string siteName = pathname.Retrieve(11).Substring(3); ActiveDirectorySite site = new ActiveDirectorySite(this.context, siteName, true); this.sites.Add(site); } } }
public bool Contains(ActiveDirectorySite site) { throw new NotImplementedException(); }