public ADPropertyValueCollection this[string propertyName] { get { ADPropertyValueCollection aDPropertyValueCollection = null; bool flag = this.InnerDictionary.TryGetValue(propertyName, out aDPropertyValueCollection); this.OnGet(propertyName, aDPropertyValueCollection); if (!flag || aDPropertyValueCollection == null) { aDPropertyValueCollection = new ADPropertyValueCollection(); aDPropertyValueCollection.TrackChanges = true; if (!this._trackChanges) { this.Add(propertyName, aDPropertyValueCollection); } else { this._trackChanges = false; this.Add(propertyName, aDPropertyValueCollection); this._trackChanges = true; } } return(aDPropertyValueCollection); } }
public ADPropertyValueCollection this[string propertyName] { get { ADPropertyValueCollection aDPropertyValueCollection = null; bool flag = this.InnerDictionary.TryGetValue(propertyName, out aDPropertyValueCollection); this.OnGet(propertyName, aDPropertyValueCollection); if (!flag || aDPropertyValueCollection == null) { aDPropertyValueCollection = new ADPropertyValueCollection(); aDPropertyValueCollection.TrackChanges = true; if (!this._trackChanges) { this.Add(propertyName, aDPropertyValueCollection); } else { this._trackChanges = false; this.Add(propertyName, aDPropertyValueCollection); this._trackChanges = true; } } return aDPropertyValueCollection; } }
internal static object GetPropertyValue(ADEntity targetEntity, string propertyName) { PropertyInfo dotNetProperty = targetEntity.GetDotNetProperty(propertyName); if (dotNetProperty == null) { if (targetEntity.PropertyIsReadable(propertyName)) { ADPropertyValueCollection item = targetEntity[propertyName]; if (targetEntity.PropertyIsSingleValue(propertyName)) { if (item == null || item.Count == 0) { return(null); } else { return(item[0]); } } else { return(item); } } else { return(null); } } else { return(dotNetProperty.GetValue(targetEntity, null)); } }
public static void ToDirectoryGroupScope(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { ADGroupScope aDGroupScope = ADGroupScope.DomainLocal; if (extendedData != null) { if (extendedData.Value != null) { ADGroupScope value = (ADGroupScope)extendedData.Value; int directoryGroupTypeValue = GroupTypeUtils.GetDirectoryGroupTypeValue(value); if (!directoryObj.Contains(directoryAttributes[0])) { directoryObj.Add(directoryAttributes[0], directoryGroupTypeValue); } else { int num = (int)directoryObj[directoryAttributes[0]].Value; if (GroupTypeUtils.TryGetExtendedGroupScopeValue(num, out aDGroupScope)) { int directoryGroupTypeValue1 = GroupTypeUtils.GetDirectoryGroupTypeValue(aDGroupScope); num = num & ~directoryGroupTypeValue1; } directoryObj[directoryAttributes[0]].Value = num + directoryGroupTypeValue; return; } } else { return; } } }
private void UpdateValueCollectionChanges(string attrName, ADPropertyValueCollection valueCollection, DirectoryAttributeModificationCollection mods) { DirectoryAttributeModification directoryAttributeModification; if (valueCollection != null) { if (!valueCollection.TrackChanges) { directoryAttributeModification = this.CreateDirAttrModification(attrName, valueCollection, null); mods.Add(directoryAttributeModification); } else { if (!valueCollection.IsValuesCleared) { if (valueCollection.ReplacedValues.Count <= 0) { if (valueCollection.DeletedValues.Count > 0) { directoryAttributeModification = this.CreateDirAttrModification(attrName, valueCollection.DeletedValues, null); directoryAttributeModification.Operation = DirectoryAttributeOperation.Delete; mods.Add(directoryAttributeModification); } if (valueCollection.AddedValues.Count > 0) { directoryAttributeModification = new DirectoryAttributeModification(); directoryAttributeModification.Operation = DirectoryAttributeOperation.Add; this.CreateDirAttrModification(attrName, valueCollection.AddedValues, directoryAttributeModification); mods.Add(directoryAttributeModification); return; } } else { directoryAttributeModification = this.CreateDirAttrModification(attrName, valueCollection.ReplacedValues, null); mods.Add(directoryAttributeModification); return; } } else { directoryAttributeModification = new DirectoryAttributeModification(); directoryAttributeModification.Name = attrName; directoryAttributeModification.Operation = DirectoryAttributeOperation.Delete; mods.Add(directoryAttributeModification); return; } } return; } else { directoryAttributeModification = new DirectoryAttributeModification(); directoryAttributeModification.Name = attrName; directoryAttributeModification.Operation = DirectoryAttributeOperation.Delete; mods.Add(directoryAttributeModification); return; } }
public ADPropertyValueCollection(ADPropertyValueCollection collection) { this._doValidation = true; if (collection != null) { base.Capacity = collection.Capacity; this.BoxValue(collection); } }
internal ADObject GetDomain() { this.Init(); GetADDomainRequest getADDomainRequest = new GetADDomainRequest(); GetADDomainResponse aDDomain = this._topoMgmt.GetADDomain(this._sessionHandle, getADDomainRequest); if (aDDomain.Domain == null) { return(null); } else { ActiveDirectoryDomain domain = aDDomain.Domain; ADObject aDObject = new ADObject(); aDObject.Add("objectGUID", domain.ObjectGuid); aDObject.Add("name", domain.Name); aDObject.Add("distinguishedName", domain.DistinguishedName); aDObject.Add("objectClass", domain.ObjectClass); aDObject.Add("msDS-AllowedDNSSuffixes", domain.AllowedDNSSuffixes); aDObject.Add("objectSid", new SecurityIdentifier(domain.DomainSID, 0)); aDObject.Add("msDS-Behavior-Version", (ADDomainMode)domain.DomainMode); aDObject.Add("managedBy", domain.ManagedBy); aDObject.Add("msDS-LogonTimeSyncInterval", domain.LastLogonReplicationInterval); aDObject.Add("SubordinateReferences", domain.SubordinateReferences); aDObject.Add("DNSRoot", domain.DNSRoot); aDObject.Add("LostAndFoundContainer", domain.LostAndFoundContainer); aDObject.Add("DeletedObjectsContainer", domain.DeletedObjectsContainer); aDObject.Add("QuotasContainer", domain.QuotasContainer); aDObject.Add("ReadOnlyReplicaDirectoryServers", domain.ReadOnlyReplicaDirectoryServer); aDObject.Add("ReplicaDirectoryServers", domain.ReplicaDirectoryServer); aDObject.Add("LinkedGroupPolicyObjects", domain.AppliedGroupPolicies); aDObject.Add("ChildDomains", domain.ChildDomains); aDObject.Add("ComputersContainer", domain.ComputersContainer); aDObject.Add("DomainControllersContainer", domain.DomainControllersContainer); aDObject.Add("ForeignSecurityPrincipalsContainer", domain.ForeignSecurityPrincipalsContainer); aDObject.Add("Forest", domain.Forest); aDObject.Add("InfrastructureMaster", domain.InfrastructureMaster); aDObject.Add("NetBIOSName", domain.NetBIOSName); aDObject.Add("PDCEmulator", domain.PDCEmulator); aDObject.Add("ParentDomain", domain.ParentDomain); aDObject.Add("RIDMaster", domain.RIDMaster); aDObject.Add("SystemsContainer", domain.SystemsContainer); aDObject.Add("UsersContainer", domain.UsersContainer); ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(); if (domain.ObjectTypes != null) { aDPropertyValueCollection.AddRange(domain.ObjectTypes); } aDObject.ObjectTypes = aDPropertyValueCollection; return(aDObject); } }
internal ADPropertyValueCollection ConvertFromRawAsString(DirectoryAttribute property) { if (property == null || property.Count == 0) { return(null); } else { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(property.GetValues(typeof(string))); return(aDPropertyValueCollection); } }
internal void Add(string propertyName, ADPropertyValueCollection propertyValue) { if (propertyValue != null) { this.DictionaryAdd(propertyName, propertyValue); return; } else { this.Add(propertyName, null); return; } }
internal object GetValue(string propertyName) { ADPropertyValueCollection aDPropertyValueCollection = null; if (!this.InnerDictionary.TryGetValue(propertyName, out aDPropertyValueCollection) || aDPropertyValueCollection == null) { return(null); } else { return(aDPropertyValueCollection.Value); } }
public static void ToDirectoryAccountExpirationDate(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (extendedData.Count != 0 && extendedData[0] != null) { DateTime item = (DateTime)extendedData[0]; if (item.Ticks != 0x89f7ff5f7b58000L) { AttributeConverters.ToDirectoryDateTime(extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo); return; } } directoryObj.SetValue(directoryAttributes[0], 0x7fffffffffffffffL); }
public void AddRange(ADPropertyValueCollection value) { if (value != null) { base.InnerList.AddRange(value); return; } else { DebugLogger.LogWarning("ADPropertyValueCollection", "AddRange(ADPropertyValueCollection): null value"); throw new ArgumentNullException("value"); } }
internal HashSet <string> GetAttributeListForSchemaClass(string schemaClassName) { Dictionary <string, ADObject> schemaClasses = this._adSchema.SchemaClasses; if (schemaClasses.ContainsKey(schemaClassName)) { ADObject item = schemaClasses[schemaClassName]; if (!item.Contains(SchemaConstants.Attributelist)) { HashSet <string> strs = new HashSet <string>(StringComparer.OrdinalIgnoreCase); HashSet <string> allParentClassesForSchemaClass = this.GetAllParentClassesForSchemaClass(schemaClassName); allParentClassesForSchemaClass.Add(schemaClassName); string[] strArrays = new string[4]; strArrays[0] = "systemMayContain"; strArrays[1] = "mayContain"; strArrays[2] = "mustContain"; strArrays[3] = "systemMustContain"; string[] strArrays1 = strArrays; foreach (string str in allParentClassesForSchemaClass) { ADObject aDObject = schemaClasses[str]; string[] strArrays2 = strArrays1; for (int i = 0; i < (int)strArrays2.Length; i++) { string str1 = strArrays2[i]; if (aDObject.Contains(str1)) { string[] valueList = aDObject[str1].ValueList as string[]; strs.UnionWith(valueList); } } } ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(new HashSet <string>(strs, StringComparer.OrdinalIgnoreCase)); item[SchemaConstants.Attributelist].Value = aDPropertyValueCollection; return(strs); } else { return(new HashSet <string>(item[SchemaConstants.Attributelist].Value as HashSet <string>, StringComparer.OrdinalIgnoreCase)); } } else { object[] objArray = new object[1]; objArray[0] = schemaClassName; throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.NoSchemaClassInSchemaCache, objArray)); } }
private void DictionaryAdd(string key, ADPropertyValueCollection value) { this.OnValidate(key, value); this.OnInsert(key, value); this.InnerDictionary.Add(key, value); try { this.OnInsertComplete(key, value); } catch { this.InnerDictionary.Remove(key); DebugLogger.LogWarning("ADPropertyCollection", string.Concat("Add: OnInsertComplete failed for key ", key, ". Value was ", value.ToString())); throw; } }
internal void SetValue(string propertyName, object propertyValue) { ADPropertyValueCollection aDPropertyValueCollection = null; bool flag = this.InnerDictionary.TryGetValue(propertyName, out aDPropertyValueCollection); if (!flag || aDPropertyValueCollection == null) { this.Add(propertyName, propertyValue); return; } else { aDPropertyValueCollection.Value = propertyValue; return; } }
public void AddRange(ADPropertyValueCollection <T> value) { if (value != null) { int count = value.Count; for (int i = 0; i < count; i++) { base.List.Add(value[i]); } return; } else { DebugLogger.LogWarning("ADPropertyValueCollection<T>", "AddRange(ADPropertyValueCollection): null value"); throw new ArgumentNullException("value"); } }
internal static void ToDirectoryComputerSamAccountName(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (extendedData == null || extendedData.Value == null) { AttributeConverters.ToDirectoryObject(extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo); return; } else { string value = extendedData.Value as string; if (!string.IsNullOrEmpty(value) && !value.EndsWith("$", StringComparison.OrdinalIgnoreCase)) { value = string.Concat(value, "$"); } AttributeConverters.ToDirectoryObject(extendedAttribute, directoryAttributes, new ADPropertyValueCollection(value), directoryObj, cmdletSessionInfo); return; } }
private void PopulateADObjectFromWebServiceData(ActiveDirectoryObject inputWSObject, ADObject adobjectToPopulate) { adobjectToPopulate.DistinguishedName = inputWSObject.DistinguishedName; adobjectToPopulate.SetValue("name", inputWSObject.Name); adobjectToPopulate.ObjectClass = inputWSObject.ObjectClass; adobjectToPopulate.ObjectGuid = new Guid?(inputWSObject.ObjectGuid); ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(); aDPropertyValueCollection.AddRange(inputWSObject.ObjectTypes); adobjectToPopulate.ObjectTypes = aDPropertyValueCollection; adobjectToPopulate.SessionInfo = new ADSessionInfo(inputWSObject.ReferenceServer); if (this._adSession.SessionInfo.Credential != null) { adobjectToPopulate.SessionInfo.Credential = this._adSession.SessionInfo.Credential; } adobjectToPopulate.SessionInfo.AuthType = this._adSession.SessionInfo.AuthType; adobjectToPopulate.IsSearchResult = true; }
internal static void ToDirectoryServiceAccountSamAccountName(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { int num; if (extendedData == null || extendedData.Value == null) { AttributeConverters.ToDirectoryObject(extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo); return; } else { string value = extendedData.Value as string; if (!string.IsNullOrEmpty(value)) { bool flag = value.EndsWith("$", StringComparison.OrdinalIgnoreCase); int length = value.Length; if (flag) { num = 16; } else { num = 15; } if (length <= num) { if (!flag) { value = string.Concat(value, "$"); } } else { object[] objArray = new object[1]; objArray[0] = value; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ServiceAccountNameLengthInvalid, objArray)); } } AttributeConverters.ToDirectoryObject(extendedAttribute, directoryAttributes, new ADPropertyValueCollection(value), directoryObj, cmdletSessionInfo); return; } }
private void DictionaryRemove(string key) { ADPropertyValueCollection aDPropertyValueCollection = null; if (this.InnerDictionary.TryGetValue(key, out aDPropertyValueCollection)) { this.OnValidate(key, aDPropertyValueCollection); this.OnRemove(key, aDPropertyValueCollection); this.InnerDictionary.Remove(key); try { this.OnRemoveComplete(key, aDPropertyValueCollection); } catch { this.InnerDictionary.Add(key, aDPropertyValueCollection); DebugLogger.LogWarning("ADPropertyCollection", string.Concat("Remove: OnRemoveComplete failed for key ", key)); throw; } } }
internal HashSet<string> GetAllParentClassesForSchemaClass(string schemaClassName) { Dictionary<string, ADObject> schemaClasses = this._adSchema.SchemaClasses; if (schemaClasses.ContainsKey(schemaClassName)) { ADObject item = schemaClasses[schemaClassName]; if (!item.Contains(SchemaConstants.ParentClasslist)) { HashSet<string> strs = new HashSet<string>(StringComparer.OrdinalIgnoreCase); HashSet<string> strs1 = new HashSet<string>(StringComparer.OrdinalIgnoreCase); if (item.Contains("subClassOf")) { string value = (string)item["subClassOf"].Value; if (string.Compare(value, schemaClassName, StringComparison.OrdinalIgnoreCase) != 0) { strs1.Add(value); } } if (item.Contains("auxiliaryClass")) { string[] valueList = item["auxiliaryClass"].ValueList as string[]; strs1.UnionWith(valueList); } if (item.Contains("systemAuxiliaryClass")) { string[] strArrays = item["systemAuxiliaryClass"].ValueList as string[]; strs1.UnionWith(strArrays); } strs.UnionWith(strs1); foreach (string str in strs1) { if (schemaClasses.ContainsKey(str)) { HashSet<string> allParentClassesForSchemaClass = this.GetAllParentClassesForSchemaClass(str); strs.UnionWith(allParentClassesForSchemaClass); } else { object[] objArray = new object[1]; objArray[0] = str; throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.NoSchemaClassInSchemaCache, objArray)); } } strs.Add(schemaClassName); ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(new HashSet<string>(strs, StringComparer.OrdinalIgnoreCase)); item[SchemaConstants.ParentClasslist].Value = aDPropertyValueCollection; return strs; } else { return new HashSet<string>(item[SchemaConstants.ParentClasslist].Value as HashSet<string>, StringComparer.OrdinalIgnoreCase); } } else { object[] objArray1 = new object[1]; objArray1[0] = schemaClassName; throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.NoSchemaClassInSchemaCache, objArray1)); } }
internal HashSet<string> GetAttributeListForSchemaClass(string schemaClassName) { Dictionary<string, ADObject> schemaClasses = this._adSchema.SchemaClasses; if (schemaClasses.ContainsKey(schemaClassName)) { ADObject item = schemaClasses[schemaClassName]; if (!item.Contains(SchemaConstants.Attributelist)) { HashSet<string> strs = new HashSet<string>(StringComparer.OrdinalIgnoreCase); HashSet<string> allParentClassesForSchemaClass = this.GetAllParentClassesForSchemaClass(schemaClassName); allParentClassesForSchemaClass.Add(schemaClassName); string[] strArrays = new string[4]; strArrays[0] = "systemMayContain"; strArrays[1] = "mayContain"; strArrays[2] = "mustContain"; strArrays[3] = "systemMustContain"; string[] strArrays1 = strArrays; foreach (string str in allParentClassesForSchemaClass) { ADObject aDObject = schemaClasses[str]; string[] strArrays2 = strArrays1; for (int i = 0; i < (int)strArrays2.Length; i++) { string str1 = strArrays2[i]; if (aDObject.Contains(str1)) { string[] valueList = aDObject[str1].ValueList as string[]; strs.UnionWith(valueList); } } } ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(new HashSet<string>(strs, StringComparer.OrdinalIgnoreCase)); item[SchemaConstants.Attributelist].Value = aDPropertyValueCollection; return strs; } else { return new HashSet<string>(item[SchemaConstants.Attributelist].Value as HashSet<string>, StringComparer.OrdinalIgnoreCase); } } else { object[] objArray = new object[1]; objArray[0] = schemaClassName; throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.NoSchemaClassInSchemaCache, objArray)); } }
internal ADPropertyValueCollection ConvertFromRaw(DirectoryAttribute property) { string str = null; int num = 0; this.Init(); if (property == null || property.Count == 0) { return(null); } else { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(); ADObjectSearcher.ContainsRangeRetrievalTag(property.Name, out str, out num); ADAttributeSyntax propertyType = this._adSchema.GetPropertyType(str); string[] values = null; byte[][] numArray = null; ADAttributeSyntax aDAttributeSyntax = propertyType; switch (aDAttributeSyntax) { case ADAttributeSyntax.DirectoryString: case ADAttributeSyntax.DN: { aDPropertyValueCollection.AddRange(property.GetValues(typeof(string))); break; } case ADAttributeSyntax.OctetString: { aDPropertyValueCollection.AddRange(property.GetValues(typeof(byte[]))); break; } case ADAttributeSyntax.SecurityDescriptor: { numArray = (byte[][])property.GetValues(typeof(byte[])); byte[][] numArray1 = numArray; for (int i = 0; i < (int)numArray1.Length; i++) { byte[] numArray2 = numArray1[i]; ActiveDirectorySecurity activeDirectorySecurity = new ActiveDirectorySecurity(); activeDirectorySecurity.SetSecurityDescriptorBinaryForm(numArray2); aDPropertyValueCollection.Add(activeDirectorySecurity); } break; } case ADAttributeSyntax.Int: case ADAttributeSyntax.Enumeration: { values = (string[])property.GetValues(typeof(string)); string[] strArrays = values; for (int j = 0; j < (int)strArrays.Length; j++) { string str1 = strArrays[j]; aDPropertyValueCollection.Add(int.Parse(str1, NumberFormatInfo.InvariantInfo)); } break; } case ADAttributeSyntax.Int64: { values = (string[])property.GetValues(typeof(string)); string[] strArrays1 = values; for (int k = 0; k < (int)strArrays1.Length; k++) { string str2 = strArrays1[k]; aDPropertyValueCollection.Add(long.Parse(str2, NumberFormatInfo.InvariantInfo)); } break; } case ADAttributeSyntax.Bool: { values = (string[])property.GetValues(typeof(string)); string[] strArrays2 = values; for (int l = 0; l < (int)strArrays2.Length; l++) { string str3 = strArrays2[l]; if (string.Compare(str3, "TRUE", StringComparison.OrdinalIgnoreCase) != 0) { aDPropertyValueCollection.Add(false); } else { aDPropertyValueCollection.Add(true); } } break; } case ADAttributeSyntax.Oid: case ADAttributeSyntax.DNWithBinary: case ADAttributeSyntax.DNWithString: case ADAttributeSyntax.IA5String: case ADAttributeSyntax.PrintableString: { aDPropertyValueCollection.AddRange(property.GetValues(typeof(string))); break; } case ADAttributeSyntax.GeneralizedTime: case ADAttributeSyntax.UtcTime: { values = (string[])property.GetValues(typeof(string)); string[] strArrays3 = values; for (int m = 0; m < (int)strArrays3.Length; m++) { string str4 = strArrays3[m]; aDPropertyValueCollection.Add(ADTypeConverter.ParseDateTimeValue(str4, propertyType)); } break; } case ADAttributeSyntax.Sid: { numArray = (byte[][])property.GetValues(typeof(byte[])); byte[][] numArray3 = numArray; for (int n = 0; n < (int)numArray3.Length; n++) { byte[] numArray4 = numArray3[n]; aDPropertyValueCollection.Add(new SecurityIdentifier(numArray4, 0)); } break; } default: { if (aDAttributeSyntax == ADAttributeSyntax.ReplicaLink) { aDPropertyValueCollection.AddRange(property.GetValues(typeof(byte[]))); break; } aDPropertyValueCollection.AddRange(property.GetValues(typeof(string))); break; } } return(aDPropertyValueCollection); } }
internal ADPropertyValueCollection ConvertFromRaw(DirectoryAttribute property) { string str = null; int num = 0; this.Init(); if (property == null || property.Count == 0) { return null; } else { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(); ADObjectSearcher.ContainsRangeRetrievalTag(property.Name, out str, out num); ADAttributeSyntax propertyType = this._adSchema.GetPropertyType(str); string[] values = null; byte[][] numArray = null; ADAttributeSyntax aDAttributeSyntax = propertyType; switch (aDAttributeSyntax) { case ADAttributeSyntax.DirectoryString: case ADAttributeSyntax.DN: { aDPropertyValueCollection.AddRange(property.GetValues(typeof(string))); break; } case ADAttributeSyntax.OctetString: { aDPropertyValueCollection.AddRange(property.GetValues(typeof(byte[]))); break; } case ADAttributeSyntax.SecurityDescriptor: { numArray = (byte[][])property.GetValues(typeof(byte[])); byte[][] numArray1 = numArray; for (int i = 0; i < (int)numArray1.Length; i++) { byte[] numArray2 = numArray1[i]; ActiveDirectorySecurity activeDirectorySecurity = new ActiveDirectorySecurity(); activeDirectorySecurity.SetSecurityDescriptorBinaryForm(numArray2); aDPropertyValueCollection.Add(activeDirectorySecurity); } break; } case ADAttributeSyntax.Int: case ADAttributeSyntax.Enumeration: { values = (string[])property.GetValues(typeof(string)); string[] strArrays = values; for (int j = 0; j < (int)strArrays.Length; j++) { string str1 = strArrays[j]; aDPropertyValueCollection.Add(int.Parse(str1, NumberFormatInfo.InvariantInfo)); } break; } case ADAttributeSyntax.Int64: { values = (string[])property.GetValues(typeof(string)); string[] strArrays1 = values; for (int k = 0; k < (int)strArrays1.Length; k++) { string str2 = strArrays1[k]; aDPropertyValueCollection.Add(long.Parse(str2, NumberFormatInfo.InvariantInfo)); } break; } case ADAttributeSyntax.Bool: { values = (string[])property.GetValues(typeof(string)); string[] strArrays2 = values; for (int l = 0; l < (int)strArrays2.Length; l++) { string str3 = strArrays2[l]; if (string.Compare(str3, "TRUE", StringComparison.OrdinalIgnoreCase) != 0) { aDPropertyValueCollection.Add(false); } else { aDPropertyValueCollection.Add(true); } } break; } case ADAttributeSyntax.Oid: case ADAttributeSyntax.DNWithBinary: case ADAttributeSyntax.DNWithString: case ADAttributeSyntax.IA5String: case ADAttributeSyntax.PrintableString: { aDPropertyValueCollection.AddRange(property.GetValues(typeof(string))); break; } case ADAttributeSyntax.GeneralizedTime: case ADAttributeSyntax.UtcTime: { values = (string[])property.GetValues(typeof(string)); string[] strArrays3 = values; for (int m = 0; m < (int)strArrays3.Length; m++) { string str4 = strArrays3[m]; aDPropertyValueCollection.Add(ADTypeConverter.ParseDateTimeValue(str4, propertyType)); } break; } case ADAttributeSyntax.Sid: { numArray = (byte[][])property.GetValues(typeof(byte[])); byte[][] numArray3 = numArray; for (int n = 0; n < (int)numArray3.Length; n++) { byte[] numArray4 = numArray3[n]; aDPropertyValueCollection.Add(new SecurityIdentifier(numArray4, 0)); } break; } default: { if (aDAttributeSyntax == ADAttributeSyntax.ReplicaLink) { aDPropertyValueCollection.AddRange(property.GetValues(typeof(byte[]))); break; } aDPropertyValueCollection.AddRange(property.GetValues(typeof(string))); break; } } return aDPropertyValueCollection; } }
private static ADPropertyValueCollection ConvertLinkedGroupPolicyObjects(string rawGPLink) { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(); if (rawGPLink != null && rawGPLink.Length > 0) { string[] strArrays = rawGPLink.Split(GPLinkUtil.GpLinkSplitChars, StringSplitOptions.RemoveEmptyEntries); if (strArrays != null && (int)strArrays.Length > 0) { string[] strArrays1 = strArrays; for (int i = 0; i < (int)strArrays1.Length; i++) { string str = strArrays1[i]; Match match = GPLinkUtil.GpLinkRegEx.Match(str); if (match.Success) { aDPropertyValueCollection.Add(match.Groups[GPLinkUtil.GpLinkRegExDNGroup].Value); } } } } return aDPropertyValueCollection; }
public override void SetPropertyValue(PSAdaptedProperty property, object valueObject) { Type realType; Type type; object obj = null; Exception exception = null; if (property != null) { ADEntity baseObject = property.BaseObject as ADEntity; if (baseObject != null) { PSObject pSObject = valueObject as PSObject; if (pSObject != null) { valueObject = pSObject.BaseObject; } PropertyInfo dotNetProperty = baseObject.GetDotNetProperty(property.Name); if (dotNetProperty == null) { if (this.IsSettable(property)) { if (valueObject != null) { realType = this.GetRealType(baseObject.GetPropertyType(property.Name)); type = this.GetRealType(valueObject.GetType()); if (realType == typeof(object) || realType == type) { baseObject[property.Name].Value = valueObject; return; } else { if (baseObject.PropertyIsSingleValue(property.Name) || valueObject as ICollection == null) { baseObject[property.Name].Value = this.ConvertValue(property, valueObject, realType, type); return; } else { if (!this.TryConvertValue(property, valueObject, realType, type, out obj, out exception)) { ICollection collections = valueObject as ICollection; ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(); foreach (object obj1 in collections) { if (obj1 == null) { continue; } Type type1 = obj1.GetType(); if (type1 != realType) { aDPropertyValueCollection.Add(this.ConvertValue(property, obj1, realType, type1)); } else { aDPropertyValueCollection.Add(obj1); } } baseObject[property.Name].Value = aDPropertyValueCollection; return; } else { baseObject[property.Name].Value = obj; return; } } } } else { baseObject[property.Name].Value = null; return; } } else { object[] name = new object[1]; name[0] = property.Name; throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.PropertyIsReadonly, name)); } } else { if (dotNetProperty.CanWrite) { if (valueObject != null) { realType = this.GetRealType(dotNetProperty.PropertyType); type = this.GetRealType(valueObject.GetType()); if (realType == typeof(object) || realType == type) { dotNetProperty.SetValue(baseObject, valueObject, null); return; } else { dotNetProperty.SetValue(baseObject, this.ConvertValue(property, valueObject, realType, type), null); return; } } else { dotNetProperty.SetValue(baseObject, null, null); return; } } else { object[] objArray = new object[1]; objArray[0] = property.Name; throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.PropertyIsReadonly, objArray)); } } } else { object[] typeAdapterTypeName = new object[2]; typeAdapterTypeName[0] = ADEntityAdapter.TypeAdapterTypeName; typeAdapterTypeName[1] = ADEntityAdapter.ADEntityTypeName; throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.TypeAdapterForADEntityOnly, typeAdapterTypeName)); } } else { throw new ArgumentNullException("property"); } }
internal void Add(string propertyName, object propertyValue) { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(propertyValue); this.DictionaryAdd(propertyName, aDPropertyValueCollection); }
public void SetProperty(string path, PSObject propertyValue) { ADPropertyValueCollection aDPropertyValueCollection; ADPropertyValueCollection item; ADPropertyValueCollection aDPropertyValueCollection1; ADPropertyValueCollection item1; PSObject pSObject = new PSObject(); Collection<string> strs = new Collection<string>(); this.Trace(DebugLogLevel.Verbose, "Entering SetProperty"); if (propertyValue != null) { if (!this.IsValidRootDSEPath(path)) { path = this.ValidateAndNormalizePath(path); ADProviderSetPropertyParameters dynamicParameters = base.DynamicParameters as ADProviderSetPropertyParameters; ADSessionInfo sessionInfo = this.GetSessionInfo(dynamicParameters, base.Credential, this.ExtendedDriveInfo); if (this.ValidateDynamicParameters(path, dynamicParameters, sessionInfo)) { ADObject aDObject = new ADObject(); aDObject.DistinguishedName = path; ADActiveObject aDActiveObject = new ADActiveObject(sessionInfo, aDObject); if (dynamicParameters != null) { if (dynamicParameters.ReplacePropertyValue != null) { foreach (string key in dynamicParameters.ReplacePropertyValue.Keys) { object obj = dynamicParameters.ReplacePropertyValue[key]; if (!aDObject.Contains(key)) { aDPropertyValueCollection = new ADPropertyValueCollection(); aDObject.Add(key, aDPropertyValueCollection); } else { aDPropertyValueCollection = aDObject[key]; aDPropertyValueCollection.Clear(); } if (obj.GetType() != typeof(object[])) { aDPropertyValueCollection.Add(obj); } else { object[] objArray = (object[])obj; for (int i = 0; i < (int)objArray.Length; i++) { object obj1 = objArray[i]; aDPropertyValueCollection.Add(obj1); } } strs.Add(key); } } if (dynamicParameters.AddPropertyValue != null) { foreach (string str in dynamicParameters.AddPropertyValue.Keys) { object item2 = dynamicParameters.AddPropertyValue[str]; if (item2 != null) { if (!aDObject.Contains(str)) { item = new ADPropertyValueCollection(); item.TrackChanges = true; aDObject.Add(str, item); } else { item = aDObject[str]; } if (item2.GetType() != typeof(object[])) { item.Add(item2); } else { object[] objArray1 = (object[])item2; for (int j = 0; j < (int)objArray1.Length; j++) { object obj2 = objArray1[j]; item.Add(obj2); } } strs.Add(str); } else { base.WriteError(ADUtilities.GetErrorRecord(new ArgumentException(StringResources.ADProviderPropertyValueCannotBeNull), "ADProvider: SetProperty: InvalidArgument", path)); this.Trace(DebugLogLevel.Error, "Leaving SetProperty: ArgumentException: addPropertyValue has null value."); return; } } } if (dynamicParameters.RemovePropertyValue != null) { foreach (string key1 in dynamicParameters.RemovePropertyValue.Keys) { object item3 = dynamicParameters.RemovePropertyValue[key1]; if (!aDObject.Contains(key1)) { aDPropertyValueCollection1 = new ADPropertyValueCollection(); aDPropertyValueCollection1.TrackChanges = true; aDObject.Add(key1, aDPropertyValueCollection1); } else { aDPropertyValueCollection1 = aDObject[key1]; } if (item3.GetType() != typeof(object[])) { aDPropertyValueCollection1.Remove(item3); } else { object[] objArray2 = (object[])item3; for (int k = 0; k < (int)objArray2.Length; k++) { object obj3 = objArray2[k]; aDPropertyValueCollection1.Remove(obj3); } } strs.Add(key1); } } } foreach (PSMemberInfo property in propertyValue.Properties) { string name = property.Name; object value = property.Value; if (!aDObject.Contains(name)) { item1 = new ADPropertyValueCollection(); item1.TrackChanges = true; aDObject.Add(name, item1); } else { item1 = aDObject[name]; } if (value.GetType() != typeof(object[])) { item1.Value = value; } else { item1.Clear(); object[] objArray3 = (object[])value; for (int l = 0; l < (int)objArray3.Length; l++) { object obj4 = objArray3[l]; item1.Add(obj4); } } strs.Add(name); } if (base.ShouldProcess(path, "Set")) { using (aDActiveObject) { try { aDActiveObject.Update(); aDObject = this.GetValidatedADObject(path, strs, dynamicParameters, base.Credential, this.ExtendedDriveInfo); } catch (ADException aDException1) { ADException aDException = aDException1; base.WriteError(ADUtilities.GetErrorRecord(aDException, "ADProvider:SetProperty:ADError", path)); this.Trace(DebugLogLevel.Error, "Leaving SetProperty: ADException: AD error"); return; } catch (UnauthorizedAccessException unauthorizedAccessException1) { UnauthorizedAccessException unauthorizedAccessException = unauthorizedAccessException1; base.WriteError(ADUtilities.GetErrorRecord(unauthorizedAccessException, "ADProvider:SetProperty:AccessDenied", path)); this.Trace(DebugLogLevel.Error, "Leaving SetProperty: ADException: access denied"); return; } catch (AuthenticationException authenticationException1) { AuthenticationException authenticationException = authenticationException1; base.WriteError(ADUtilities.GetErrorRecord(authenticationException, "ADProvider:SetProperty:InvalidCredentials", path)); this.Trace(DebugLogLevel.Error, "Leaving SetProperty: ADException: invalid credentials"); return; } catch (InvalidOperationException invalidOperationException1) { InvalidOperationException invalidOperationException = invalidOperationException1; base.WriteError(ADUtilities.GetErrorRecord(invalidOperationException, "ADProvider:SetProperty:InvalidOperation", path)); this.Trace(DebugLogLevel.Error, "Leaving SetProperty: ADException: invalid operation"); return; } } foreach (string str1 in strs) { pSObject.Properties.Add(new PSNoteProperty(str1, aDObject[str1].Value)); } this.WriteADObjectProperties(aDObject, pSObject, dynamicParameters, this.ExtendedDriveInfo); this.Trace(DebugLogLevel.Verbose, "Leaving SetProperty"); return; } else { this.Trace(DebugLogLevel.Info, "Leaving SetProperty: ShouldProcess returned false."); } return; } else { this.Trace(DebugLogLevel.Error, "Leaving GetProperty: ValidateDynamicParameters: returned false"); return; } } else { base.WriteError(ADUtilities.GetErrorRecord(new NotSupportedException(StringResources.ADProviderOperationNotSupportedForRootDSE), "NotSupported", path)); this.Trace(DebugLogLevel.Error, "Leaving SetProperty: NotSupportedException: path is rootdse"); return; } } else { base.WriteError(ADUtilities.GetErrorRecord(new ArgumentNullException("propertyValue"), "ADProvider:SetProperty:NullArgument", path)); this.Trace(DebugLogLevel.Error, "Leaving SetProperty: ArgumentNullException: propertyValue is null"); return; } }
internal bool TryGetValue(string propertyName, out ADPropertyValueCollection value) { return this.InnerDictionary.TryGetValue(propertyName, out value); }
internal HashSet <string> GetAllParentClassesForSchemaClass(string schemaClassName) { Dictionary <string, ADObject> schemaClasses = this._adSchema.SchemaClasses; if (schemaClasses.ContainsKey(schemaClassName)) { ADObject item = schemaClasses[schemaClassName]; if (!item.Contains(SchemaConstants.ParentClasslist)) { HashSet <string> strs = new HashSet <string>(StringComparer.OrdinalIgnoreCase); HashSet <string> strs1 = new HashSet <string>(StringComparer.OrdinalIgnoreCase); if (item.Contains("subClassOf")) { string value = (string)item["subClassOf"].Value; if (string.Compare(value, schemaClassName, StringComparison.OrdinalIgnoreCase) != 0) { strs1.Add(value); } } if (item.Contains("auxiliaryClass")) { string[] valueList = item["auxiliaryClass"].ValueList as string[]; strs1.UnionWith(valueList); } if (item.Contains("systemAuxiliaryClass")) { string[] strArrays = item["systemAuxiliaryClass"].ValueList as string[]; strs1.UnionWith(strArrays); } strs.UnionWith(strs1); foreach (string str in strs1) { if (schemaClasses.ContainsKey(str)) { HashSet <string> allParentClassesForSchemaClass = this.GetAllParentClassesForSchemaClass(str); strs.UnionWith(allParentClassesForSchemaClass); } else { object[] objArray = new object[1]; objArray[0] = str; throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.NoSchemaClassInSchemaCache, objArray)); } } strs.Add(schemaClassName); ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(new HashSet <string>(strs, StringComparer.OrdinalIgnoreCase)); item[SchemaConstants.ParentClasslist].Value = aDPropertyValueCollection; return(strs); } else { return(new HashSet <string>(item[SchemaConstants.ParentClasslist].Value as HashSet <string>, StringComparer.OrdinalIgnoreCase)); } } else { object[] objArray1 = new object[1]; objArray1[0] = schemaClassName; throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.NoSchemaClassInSchemaCache, objArray1)); } }
internal virtual void InvokeToDirectoryConverter(ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { this._toDirectoryDelegate(base.ExtendedAttribute, this.DirectoryAttributes, extendedData, directoryObj, cmdletSessionInfo); }
internal bool TryGetValue(string propertyName, out ADPropertyValueCollection value) { return(this.InnerDictionary.TryGetValue(propertyName, out value)); }
internal ADPropertyValueCollection ConvertFromRaw(string propertyName, ADPropertyValueCollection propertyValues) { string str = null; int num = 0; ADPropertyValueCollection aDPropertyValueCollection; byte[] bytes; this.Init(); if (propertyValues.Count != 0) { ADObjectSearcher.ContainsRangeRetrievalTag(propertyName, out str, out num); ADAttributeSyntax propertyType = this._adSchema.GetPropertyType(str); ADAttributeSyntax aDAttributeSyntax = propertyType; switch (aDAttributeSyntax) { case ADAttributeSyntax.DirectoryString: case ADAttributeSyntax.DN: { aDPropertyValueCollection = propertyValues; break; } case ADAttributeSyntax.OctetString: { aDPropertyValueCollection = propertyValues; break; } case ADAttributeSyntax.SecurityDescriptor: { aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count); IEnumerator enumerator = propertyValues.GetEnumerator(); try { while (enumerator.MoveNext()) { byte[] current = (byte[])enumerator.Current; ActiveDirectorySecurity activeDirectorySecurity = new ActiveDirectorySecurity(); activeDirectorySecurity.SetSecurityDescriptorBinaryForm(current); aDPropertyValueCollection.Add(activeDirectorySecurity); } break; } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } } case ADAttributeSyntax.Int: case ADAttributeSyntax.Enumeration: { aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count); IEnumerator enumerator1 = propertyValues.GetEnumerator(); try { while (enumerator1.MoveNext()) { string current1 = (string)enumerator1.Current; aDPropertyValueCollection.Add(int.Parse(current1, NumberFormatInfo.InvariantInfo)); } break; } finally { IDisposable disposable1 = enumerator1 as IDisposable; if (disposable1 != null) { disposable1.Dispose(); } } } case ADAttributeSyntax.Int64: { aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count); IEnumerator enumerator2 = propertyValues.GetEnumerator(); try { while (enumerator2.MoveNext()) { string str1 = (string)enumerator2.Current; aDPropertyValueCollection.Add(long.Parse(str1, NumberFormatInfo.InvariantInfo)); } break; } finally { IDisposable disposable2 = enumerator2 as IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } } case ADAttributeSyntax.Bool: { aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count); IEnumerator enumerator3 = propertyValues.GetEnumerator(); try { while (enumerator3.MoveNext()) { string current2 = (string)enumerator3.Current; if (string.Compare(current2, "TRUE", StringComparison.OrdinalIgnoreCase) != 0) { aDPropertyValueCollection.Add(false); } else { aDPropertyValueCollection.Add(true); } } break; } finally { IDisposable disposable3 = enumerator3 as IDisposable; if (disposable3 != null) { disposable3.Dispose(); } } } case ADAttributeSyntax.Oid: case ADAttributeSyntax.DNWithBinary: case ADAttributeSyntax.DNWithString: case ADAttributeSyntax.IA5String: case ADAttributeSyntax.PrintableString: { aDPropertyValueCollection = propertyValues; break; } case ADAttributeSyntax.GeneralizedTime: case ADAttributeSyntax.UtcTime: { aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count); IEnumerator enumerator4 = propertyValues.GetEnumerator(); try { while (enumerator4.MoveNext()) { string str2 = (string)enumerator4.Current; aDPropertyValueCollection.Add(ADTypeConverter.ParseDateTimeValue(str2, propertyType)); } break; } finally { IDisposable disposable4 = enumerator4 as IDisposable; if (disposable4 != null) { disposable4.Dispose(); } } } case ADAttributeSyntax.Sid: { aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count); IEnumerator enumerator5 = propertyValues.GetEnumerator(); try { while (enumerator5.MoveNext()) { object obj = enumerator5.Current; if (obj as string == null) { bytes = (byte[])obj; } else { bytes = ADTypeConverter._encoder.GetBytes((string)obj); } aDPropertyValueCollection.Add(new SecurityIdentifier(bytes, 0)); } break; } finally { IDisposable disposable5 = enumerator5 as IDisposable; if (disposable5 != null) { disposable5.Dispose(); } } } default: { aDPropertyValueCollection = propertyValues; break; } } return(aDPropertyValueCollection); } else { return(null); } }
internal ADPropertyValueCollection ConvertFromRaw(string propertyName, ADPropertyValueCollection propertyValues) { string str = null; int num = 0; ADPropertyValueCollection aDPropertyValueCollection; byte[] bytes; this.Init(); if (propertyValues.Count != 0) { ADObjectSearcher.ContainsRangeRetrievalTag(propertyName, out str, out num); ADAttributeSyntax propertyType = this._adSchema.GetPropertyType(str); ADAttributeSyntax aDAttributeSyntax = propertyType; switch (aDAttributeSyntax) { case ADAttributeSyntax.DirectoryString: case ADAttributeSyntax.DN: { aDPropertyValueCollection = propertyValues; break; } case ADAttributeSyntax.OctetString: { aDPropertyValueCollection = propertyValues; break; } case ADAttributeSyntax.SecurityDescriptor: { aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count); IEnumerator enumerator = propertyValues.GetEnumerator(); try { while (enumerator.MoveNext()) { byte[] current = (byte[])enumerator.Current; ActiveDirectorySecurity activeDirectorySecurity = new ActiveDirectorySecurity(); activeDirectorySecurity.SetSecurityDescriptorBinaryForm(current); aDPropertyValueCollection.Add(activeDirectorySecurity); } break; } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } } case ADAttributeSyntax.Int: case ADAttributeSyntax.Enumeration: { aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count); IEnumerator enumerator1 = propertyValues.GetEnumerator(); try { while (enumerator1.MoveNext()) { string current1 = (string)enumerator1.Current; aDPropertyValueCollection.Add(int.Parse(current1, NumberFormatInfo.InvariantInfo)); } break; } finally { IDisposable disposable1 = enumerator1 as IDisposable; if (disposable1 != null) { disposable1.Dispose(); } } } case ADAttributeSyntax.Int64: { aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count); IEnumerator enumerator2 = propertyValues.GetEnumerator(); try { while (enumerator2.MoveNext()) { string str1 = (string)enumerator2.Current; aDPropertyValueCollection.Add(long.Parse(str1, NumberFormatInfo.InvariantInfo)); } break; } finally { IDisposable disposable2 = enumerator2 as IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } } case ADAttributeSyntax.Bool: { aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count); IEnumerator enumerator3 = propertyValues.GetEnumerator(); try { while (enumerator3.MoveNext()) { string current2 = (string)enumerator3.Current; if (string.Compare(current2, "TRUE", StringComparison.OrdinalIgnoreCase) != 0) { aDPropertyValueCollection.Add(false); } else { aDPropertyValueCollection.Add(true); } } break; } finally { IDisposable disposable3 = enumerator3 as IDisposable; if (disposable3 != null) { disposable3.Dispose(); } } } case ADAttributeSyntax.Oid: case ADAttributeSyntax.DNWithBinary: case ADAttributeSyntax.DNWithString: case ADAttributeSyntax.IA5String: case ADAttributeSyntax.PrintableString: { aDPropertyValueCollection = propertyValues; break; } case ADAttributeSyntax.GeneralizedTime: case ADAttributeSyntax.UtcTime: { aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count); IEnumerator enumerator4 = propertyValues.GetEnumerator(); try { while (enumerator4.MoveNext()) { string str2 = (string)enumerator4.Current; aDPropertyValueCollection.Add(ADTypeConverter.ParseDateTimeValue(str2, propertyType)); } break; } finally { IDisposable disposable4 = enumerator4 as IDisposable; if (disposable4 != null) { disposable4.Dispose(); } } } case ADAttributeSyntax.Sid: { aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count); IEnumerator enumerator5 = propertyValues.GetEnumerator(); try { while (enumerator5.MoveNext()) { object obj = enumerator5.Current; if (obj as string == null) { bytes = (byte[])obj; } else { bytes = ADTypeConverter._encoder.GetBytes((string)obj); } aDPropertyValueCollection.Add(new SecurityIdentifier(bytes, 0)); } break; } finally { IDisposable disposable5 = enumerator5 as IDisposable; if (disposable5 != null) { disposable5.Dispose(); } } } default: { aDPropertyValueCollection = propertyValues; break; } } return aDPropertyValueCollection; } else { return null; } }
public void SetSecurityDescriptor(string path, ObjectSecurity securityDescriptor) { ADPropertyValueCollection aDPropertyValueCollection; this.Trace(DebugLogLevel.Verbose, "Entering SetSecurityDescriptor"); Collection<string> strs = new Collection<string>(); if (!this.IsValidRootDSEPath(path)) { path = this.ValidateAndNormalizePath(path); if (securityDescriptor != null) { ActiveDirectorySecurity activeDirectorySecurity = securityDescriptor as ActiveDirectorySecurity; if (activeDirectorySecurity != null) { if (base.ShouldProcess(path, "Set")) { ADSessionInfo sessionInfo = this.GetSessionInfo(null, base.Credential, this.ExtendedDriveInfo); ADObject aDObject = new ADObject(); aDObject.DistinguishedName = path; ADActiveObject aDActiveObject = new ADActiveObject(sessionInfo, aDObject); strs.Add("ntSecurityDescriptor"); aDActiveObject.SecurityDescriptorFlags = SecurityMasks.None; using (aDActiveObject) { try { if (!aDObject.Contains("ntSecurityDescriptor")) { aDPropertyValueCollection = new ADPropertyValueCollection(); aDObject.Add("ntSecurityDescriptor", aDPropertyValueCollection); } else { aDPropertyValueCollection = aDObject["ntSecurityDescriptor"]; } aDObject["ntSecurityDescriptor"].Value = activeDirectorySecurity; aDActiveObject.Update(); aDObject = this.GetValidatedADObject(path, strs, null, base.Credential, this.ExtendedDriveInfo); } catch (ADException aDException1) { ADException aDException = aDException1; base.WriteError(ADUtilities.GetErrorRecord(aDException, "ADProvider:SetSecurityDescriptor:ADError", path)); this.Trace(DebugLogLevel.Error, "Leaving SetSecurityDescriptor: ADException: AD error"); return; } catch (UnauthorizedAccessException unauthorizedAccessException1) { UnauthorizedAccessException unauthorizedAccessException = unauthorizedAccessException1; base.WriteError(ADUtilities.GetErrorRecord(unauthorizedAccessException, "ADProvider:SetSecurityDescriptor:AccessDenied", path)); this.Trace(DebugLogLevel.Error, "Leaving SetSecurityDescriptor: ADException: access denied"); return; } catch (AuthenticationException authenticationException1) { AuthenticationException authenticationException = authenticationException1; base.WriteError(ADUtilities.GetErrorRecord(authenticationException, "ADProvider:SetSecurityDescriptor:InvalidCredentials", path)); this.Trace(DebugLogLevel.Error, "Leaving SetSecurityDescriptor: ADException: invalid credentials"); return; } catch (InvalidOperationException invalidOperationException1) { InvalidOperationException invalidOperationException = invalidOperationException1; base.WriteError(ADUtilities.GetErrorRecord(invalidOperationException, "ADProvider:SetSecurityDescriptor:InvalidOperation", path)); this.Trace(DebugLogLevel.Error, "Leaving SetSecurityDescriptor: ADException: invalid operation"); return; } this.WriteADObjectSecurityDescriptor(aDObject, activeDirectorySecurity, null, this.ExtendedDriveInfo); this.Trace(DebugLogLevel.Verbose, "Leaving SetSecurityDescriptor"); return; } return; } else { this.Trace(DebugLogLevel.Info, "Leaving SetSecurityDescriptor: ShouldProcess returned false."); return; } } else { base.WriteError(ADUtilities.GetErrorRecord(new ArgumentException("securityDescriptor"), "ADProvider:SetSecurityDescriptor:InvalidSecurityDescriptor", path)); this.Trace(DebugLogLevel.Error, "Leaving SetSecurityDescriptor: ArgumentException: securityDescriptor is of incorrect type"); return; } } else { base.WriteError(ADUtilities.GetErrorRecord(new ArgumentException("securityDescriptor"), "ADProvider:SetSecurityDescriptor:InvalidSecurityDescriptor", path)); this.Trace(DebugLogLevel.Error, "Leaving SetSecurityDescriptor: ArgumentException: securityDescriptor is null"); return; } } else { base.WriteError(ADUtilities.GetErrorRecord(new NotSupportedException(StringResources.ADProviderOperationNotSupportedForRootDSE), "NotSupported", path)); this.Trace(DebugLogLevel.Error, "Leaving SetSecurityDescriptor: NotSupportedException: path is rootdse"); return; } }
internal ADObject GetDomain() { this.Init(); GetADDomainRequest getADDomainRequest = new GetADDomainRequest(); GetADDomainResponse aDDomain = this._topoMgmt.GetADDomain(this._sessionHandle, getADDomainRequest); if (aDDomain.Domain == null) { return null; } else { ActiveDirectoryDomain domain = aDDomain.Domain; ADObject aDObject = new ADObject(); aDObject.Add("objectGUID", domain.ObjectGuid); aDObject.Add("name", domain.Name); aDObject.Add("distinguishedName", domain.DistinguishedName); aDObject.Add("objectClass", domain.ObjectClass); aDObject.Add("msDS-AllowedDNSSuffixes", domain.AllowedDNSSuffixes); aDObject.Add("objectSid", new SecurityIdentifier(domain.DomainSID, 0)); aDObject.Add("msDS-Behavior-Version", (ADDomainMode)domain.DomainMode); aDObject.Add("managedBy", domain.ManagedBy); aDObject.Add("msDS-LogonTimeSyncInterval", domain.LastLogonReplicationInterval); aDObject.Add("SubordinateReferences", domain.SubordinateReferences); aDObject.Add("DNSRoot", domain.DNSRoot); aDObject.Add("LostAndFoundContainer", domain.LostAndFoundContainer); aDObject.Add("DeletedObjectsContainer", domain.DeletedObjectsContainer); aDObject.Add("QuotasContainer", domain.QuotasContainer); aDObject.Add("ReadOnlyReplicaDirectoryServers", domain.ReadOnlyReplicaDirectoryServer); aDObject.Add("ReplicaDirectoryServers", domain.ReplicaDirectoryServer); aDObject.Add("LinkedGroupPolicyObjects", domain.AppliedGroupPolicies); aDObject.Add("ChildDomains", domain.ChildDomains); aDObject.Add("ComputersContainer", domain.ComputersContainer); aDObject.Add("DomainControllersContainer", domain.DomainControllersContainer); aDObject.Add("ForeignSecurityPrincipalsContainer", domain.ForeignSecurityPrincipalsContainer); aDObject.Add("Forest", domain.Forest); aDObject.Add("InfrastructureMaster", domain.InfrastructureMaster); aDObject.Add("NetBIOSName", domain.NetBIOSName); aDObject.Add("PDCEmulator", domain.PDCEmulator); aDObject.Add("ParentDomain", domain.ParentDomain); aDObject.Add("RIDMaster", domain.RIDMaster); aDObject.Add("SystemsContainer", domain.SystemsContainer); aDObject.Add("UsersContainer", domain.UsersContainer); ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(); if (domain.ObjectTypes != null) { aDPropertyValueCollection.AddRange(domain.ObjectTypes); } aDObject.ObjectTypes = aDPropertyValueCollection; return aDObject; } }
internal ADPropertyValueCollection ConvertFromRawAsString(DirectoryAttribute property) { if (property == null || property.Count == 0) { return null; } else { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(property.GetValues(typeof(string))); return aDPropertyValueCollection; } }