private OleDbPermission UnionOleDb(OleDbPermission target, OleDbPermission newPermission) { if (null == target) { newPermission._providerRestriction = _providerRestriction; } else { string[] theseRestrictions = _providerRestriction; // MDAC 83107 string[] thoseRestrictions = target._providerRestriction; if (null == theseRestrictions) { newPermission._providerRestriction = thoseRestrictions; } else if (null == thoseRestrictions) { newPermission._providerRestriction = theseRestrictions; } else // union of two string[] { int a = theseRestrictions.Length; int b = thoseRestrictions.Length; string[] restrictions = new string[a + b]; theseRestrictions.CopyTo(restrictions, 0); thoseRestrictions.CopyTo(restrictions, a); newPermission._providerRestriction = DBConnectionString.RemoveDuplicates(restrictions); } } return(newPermission); }
// <IPermission class="OleDbPermission" version="1" AllowBlankPassword=false> // <keyword name="provider"> // <value value="sqloledb"/> // <value value="sqloledb.1"/> // </keyword> // </IPermission> /// <include file='doc\OleDbPermission.uex' path='docs/doc[@for="OleDbPermission.FromXml"]/*' /> override public void FromXml(SecurityElement securityElement) { base.FromXml(securityElement); ArrayList children = securityElement.Children; if (IsUnrestricted() || (null == children)) { return; } int count; Hashtable hash = new Hashtable(); foreach (SecurityElement keyElement in children) { string keyword = keyElement.Attribute(ODB._Name); if (null != keyword) { keyword = keyword.ToLower(CultureInfo.InvariantCulture); } if (keyElement.Tag.Equals(ODB._Keyword) && (null != keyword) && (ODB.Provider == keyword)) { ArrayList keyvaluepair = keyElement.Children; if (null != keyvaluepair) { count = keyvaluepair.Count; for (int i = 0; i < count; ++i) { SecurityElement valueElement = (SecurityElement)keyvaluepair[i]; string value = (string)valueElement.Attribute(ODB._Value); if (valueElement.Tag.Equals(ODB._Value) && (null != value)) { value = value.Trim(); if (0 < value.Length) { hash[value] = null; } } } } } } count = hash.Count; if (0 < count) { string[] oldrestrictions = _providerRestriction; // appending to if (null != oldrestrictions) { count += oldrestrictions.Length; } string[] restrictions = new string[count]; hash.Keys.CopyTo(restrictions, 0); if (null != oldrestrictions) { oldrestrictions.CopyTo(restrictions, count - oldrestrictions.Length); } _providerRestriction = DBConnectionString.RemoveDuplicates(restrictions); _providers = null; } }