internal void ChangePassword(string partitionDN, ADObject directoryObj, SecureString oldPassword, SecureString newPassword) { if (oldPassword == null) { oldPassword = this.PromptOldPassword(directoryObj); } if (oldPassword != null) { if (newPassword == null) { newPassword = this.PromptNewPassword(directoryObj); } if (newPassword != null) { ADPasswordUtil.PerformChangePassword(partitionDN, directoryObj, oldPassword, newPassword); return; } else { return; } } else { return; } }
internal static void PerformSetPassword(string partitionDN, ADObject directoryObj, SecureString newPassword) { ADSessionInfo sessionInfo = directoryObj.SessionInfo; using (ADAccountManagement aDAccountManagement = new ADAccountManagement(sessionInfo)) { IntPtr bSTR = Marshal.SecureStringToBSTR(newPassword); string stringUni = Marshal.PtrToStringUni(bSTR); aDAccountManagement.SetPassword(partitionDN, directoryObj.DistinguishedName, stringUni); } }
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; } }
public ADActiveObject(ADSessionInfo sessionInfo, ADObject obj) { this._sdFlags = SecurityMasks.Dacl; if (obj != null) { this._adSession = ADSession.ConstructSession(sessionInfo); this._adObject = obj; return; } else { DebugLogger.LogWarning("ADActiveObject", "Constructor(ADSessionInfo,ADObject) called with null obj"); throw new ArgumentNullException("obj"); } }
public ADDirectoryServer(ADObject identity) { if (identity != null) { base.Identity = identity; if (identity.IsSearchResult) { base.SessionInfo = identity.SessionInfo; } return; } else { throw new ArgumentException("identity"); } }
public ADPartition(ADObject adobject) { if (adobject != null) { base.Identity = adobject; if (adobject.IsSearchResult) { base.SessionInfo = adobject.SessionInfo; } return; } else { throw new ArgumentException("adobject"); } }
private ADActiveObject(ADSession session, ADObject obj) { this._sdFlags = SecurityMasks.Dacl; if (obj != null) { if (session != null) { this._adObject = obj; this._adSession = session; return; } else { DebugLogger.LogWarning("ADActiveObject", "Constructor(ADSession,ADObject) called with null session"); throw new ArgumentNullException("session"); } } else { DebugLogger.LogWarning("ADActiveObject", "Constructor(ADSession,ADObject) called with null obj"); throw new ArgumentNullException("obj"); } }
public ADCentralAccessRule(ADObject identity) { base.Identity = identity; }
public ADClaimTypeBase(ADObject identity) { base.Identity = identity; }
public ADResourcePropertyValueType(ADObject identity) { base.Identity = identity; }
public ADDomainController(ADObject identity) : base(identity) { }
public ADReplicationConnection(ADObject identity) { base.Identity = identity; }
public ADAccount(ADObject identity) : base(identity) { }
public ADUser(ADObject identity) : base(identity) { }
public ADComputer(ADObject identity) : base(identity) { }
public ADNtdsSetting(ADObject identity) { base.Identity = identity; }
public ADReplicationSubnet(ADObject identity) { base.Identity = identity; }
public ADGroup(ADObject identity) : base(identity) { }
public ADTrust(ADObject identity) { base.Identity = identity; }
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; } }
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; } }
private static void ExtractRangeRetrievalDataFromAttributes(ADObject fetchedObject, ADObject targetObject, HashSet<string> rangeRetrievedObjects, HashSet<string> rangeRetrievedAttributes, ref int rangeRetrievalNextIndex) { string str = null; int num = 0; string[] strArrays = new string[fetchedObject.PropertyNames.Count]; fetchedObject.PropertyNames.CopyTo(strArrays, 0); string[] strArrays1 = strArrays; for (int i = 0; i < (int)strArrays1.Length; i++) { string str1 = strArrays1[i]; if (ADObjectSearcher.ContainsRangeRetrievalTag(str1, out str, out num)) { rangeRetrievedObjects.Add(fetchedObject.DistinguishedName); if (num != -1) { rangeRetrievedAttributes.Add(str); if (rangeRetrievalNextIndex == -2147483648) { rangeRetrievalNextIndex = num + 1; } } //targetObject[str]; targetObject[str].AddRange(fetchedObject[str1]); if (targetObject.Contains(str1)) { targetObject.Remove(str1); } } } }
private PSObject WrapADObjectInPSObject(ADObject adObj, ADProviderCommonParameters parameters, ADDriveInfo extendedDriveInfo) { PSObject pSObject = new PSObject(adObj); ADProviderSearchParameters aDProviderSearchParameter = parameters as ADProviderSearchParameters; bool flag = true; if (aDProviderSearchParameter != null && aDProviderSearchParameter.Properties != null && (int)aDProviderSearchParameter.Properties.Length > 0) { flag = false; } if (flag) { if (this.GetFormatType(parameters, extendedDriveInfo) != ADPathFormat.Canonical) { pSObject.TypeNames.Add(string.Concat(adObj.GetType().ToString(), "#ProviderX500DefaultPropertySet")); } else { pSObject.TypeNames.Add(string.Concat(adObj.GetType().ToString(), "#ProviderCanonicalDefaultPropertySet")); } } return pSObject; }
private void WriteADRootDSEChildName(ADObject adObj, ADProviderCommonParameters parameters, ADDriveInfo extendedDriveInfo) { if (this.GetFormatType(parameters, extendedDriveInfo) != ADPathFormat.Canonical) { this.WriteItemObjectWithAbsolutePath(adObj.DistinguishedName, adObj.DistinguishedName, true); return; } else { if (!adObj.Contains("canonicalName")) { base.WriteError(ADUtilities.GetErrorRecord(new ADException(string.Format(StringResources.ADProviderUnableToReadProperty, "canonicalName", adObj.DistinguishedName)), "ADProvider:WriteADRootDSEChildName:UnableToReadCanonicalName", adObj.DistinguishedName)); this.Trace(DebugLogLevel.Error, string.Format("Leaving WriteADRootDSEChildName: Unable to read canonical name for object {0}.", adObj.DistinguishedName)); return; } else { string value = (string)adObj["canonicalName"].Value; this.WriteItemObjectWithAbsolutePath(value, value, true); return; } } }
public void ClearProperty(string path, Collection<string> propertyToClear) { this.Trace(DebugLogLevel.Verbose, "Entering ClearProperty"); PSObject pSObject = new PSObject(); if (!this.IsValidRootDSEPath(path)) { path = this.ValidateAndNormalizePath(path); if (propertyToClear != null) { if (base.ShouldProcess(path, "Clear")) { ADProviderCommonParameters dynamicParameters = base.DynamicParameters as ADProviderCommonParameters; 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); foreach (string str in propertyToClear) { aDObject.Add(str, null); } using (aDActiveObject) { try { aDActiveObject.Update(); this.Trace(DebugLogLevel.Verbose, "ClearProperty: ADObject updated in store."); aDObject = this.GetValidatedADObject(path, propertyToClear, dynamicParameters, base.Credential, this.ExtendedDriveInfo); } catch (ADException aDException1) { ADException aDException = aDException1; base.WriteError(ADUtilities.GetErrorRecord(aDException, "ADProvider:ClearProperty:ADError", path)); this.Trace(DebugLogLevel.Error, "Leaving ClearProperty: ADException: AD error"); return; } catch (UnauthorizedAccessException unauthorizedAccessException1) { UnauthorizedAccessException unauthorizedAccessException = unauthorizedAccessException1; base.WriteError(ADUtilities.GetErrorRecord(unauthorizedAccessException, "ADProvider:ClearProperty:AccessDenied", path)); this.Trace(DebugLogLevel.Error, "Leaving ClearProperty: ADException: access denied"); return; } catch (AuthenticationException authenticationException1) { AuthenticationException authenticationException = authenticationException1; base.WriteError(ADUtilities.GetErrorRecord(authenticationException, "ADProvider:ClearProperty:InvalidCredentials", path)); this.Trace(DebugLogLevel.Error, "Leaving ClearProperty: ADException: invalid credentials"); return; } catch (InvalidOperationException invalidOperationException1) { InvalidOperationException invalidOperationException = invalidOperationException1; base.WriteError(ADUtilities.GetErrorRecord(invalidOperationException, "ADProvider:ClearProperty:InvalidOperation", path)); this.Trace(DebugLogLevel.Error, "Leaving ClearProperty: ADException: invalid operation"); return; } foreach (string str1 in propertyToClear) { if (!aDObject.Contains(str1)) { continue; } pSObject.Properties.Add(new PSNoteProperty(str1, aDObject[str1].Value)); } this.WriteADObjectProperties(aDObject, pSObject, dynamicParameters, this.ExtendedDriveInfo); this.Trace(DebugLogLevel.Verbose, "Leaving ClearProperty"); return; } return; } else { this.Trace(DebugLogLevel.Error, "Leaving ClearProperty: ValidateDynamicParameters: returned false"); return; } } else { this.Trace(DebugLogLevel.Info, "Leaving ClearProperty: ShouldProcess returned false."); return; } } else { base.WriteError(ADUtilities.GetErrorRecord(new ArgumentException(StringResources.ADProviderPropertiesToClearNotSpecified), "ADProvider:ClearProperty:propertyToClear", path)); this.Trace(DebugLogLevel.Error, "Leaving ClearProperty: ArgumentException: propertyToClear is clear"); return; } } else { base.WriteError(ADUtilities.GetErrorRecord(new NotSupportedException(StringResources.ADProviderOperationNotSupportedForRootDSE), "NotSupported", path)); this.Trace(DebugLogLevel.Error, "Leaving ClearProperty: NotSupportedException: path is rootdse"); return; } }
public ADResourcePropertyList(ADObject identity) { base.Identity = identity; }
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; }
public ADOrganizationalUnit(ADObject identity) { if (identity != null) { base.Identity = identity; if (identity.IsSearchResult) { base.SessionInfo = identity.SessionInfo; } return; } else { throw new ArgumentException("identity"); } }
public ADCentralAccessPolicy(ADObject identity) { base.Identity = identity; }
public ADClaimTransformPolicy(ADObject identity) { base.Identity = identity; }
public ADServiceAccount(ADObject identity) : base(identity) { }
private ADObject CreateRichADObject(ADObject resultEntry) { ADPropertyValueCollection item; ADObject aDObject = new ADObject(); aDObject.DistinguishedName = resultEntry.DistinguishedName; bool flag = false; bool flag1 = false; bool flag2 = false; foreach (string propertyName in resultEntry.PropertyNames) { if (flag || string.Compare(propertyName, "distinguishedName", StringComparison.OrdinalIgnoreCase) != 0) { if (flag1 || string.Compare(propertyName, "objectClass", StringComparison.OrdinalIgnoreCase) != 0) { if (flag2 || string.Compare(propertyName, "objectGUID", StringComparison.OrdinalIgnoreCase) != 0) { if (!this._schemaTranslationEnabled) { aDObject.Add(propertyName, resultEntry[propertyName]); } else { aDObject.Add(propertyName, this._typeConverter.ConvertFromRaw(propertyName, resultEntry[propertyName])); } } else { item = resultEntry[propertyName]; if (item.Count <= 0) { Guid?nullable = null; aDObject.ObjectGuid = nullable; } else { object objectGuidObj = item[0]; if (objectGuidObj is string) { byte[] objGuidBytes = Encoding.Default.GetBytes((string)objectGuidObj); try { aDObject.ObjectGuid = new Guid?(new Guid(objGuidBytes)); } catch { aDObject.ObjectGuid = null; } } else if (objectGuidObj is byte[]) { aDObject.ObjectGuid = new Guid?(new Guid((byte[])item[0])); } else { aDObject.ObjectGuid = null; } } flag2 = true; } } else { item = resultEntry[propertyName]; if (item.Count <= 0) { aDObject.ObjectClass = null; } else { aDObject.ObjectClass = (string)item[item.Count - 1]; aDObject.ObjectTypes = item; } flag1 = true; } } else { flag = true; } } aDObject.IsSearchResult = true; return(aDObject); }
public ADSchemaObject(ADObject identity) { base.Identity = identity; }
public ADReplicationSiteLink(ADObject identity) { base.Identity = identity; }
public ADObjectSearcher(ADObject obj) : this(null, obj) { }
private static void ExtractRangeRetrievalDataFromAttributes(ADObject fetchedObject, ADObject targetObject, HashSet <string> rangeRetrievedObjects, HashSet <string> rangeRetrievedAttributes, ref int rangeRetrievalNextIndex) { string str = null; int num = 0; string[] strArrays = new string[fetchedObject.PropertyNames.Count]; fetchedObject.PropertyNames.CopyTo(strArrays, 0); string[] strArrays1 = strArrays; for (int i = 0; i < (int)strArrays1.Length; i++) { string str1 = strArrays1[i]; if (ADObjectSearcher.ContainsRangeRetrievalTag(str1, out str, out num)) { rangeRetrievedObjects.Add(fetchedObject.DistinguishedName); if (num != -1) { rangeRetrievedAttributes.Add(str); if (rangeRetrievalNextIndex == -2147483648) { rangeRetrievalNextIndex = num + 1; } } //targetObject[str]; targetObject[str].AddRange(fetchedObject[str1]); if (targetObject.Contains(str1)) { targetObject.Remove(str1); } } } }
public ADObjectSearcher(ADSessionInfo sessionInfo, ADObject obj) { this._searchScope = ADSearchScope.Subtree; this._filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*"); this._propertyList = new List<string>(ADObject.DefaultProperties); this._timeLimit = TimeSpan.Zero; this._schemaTranslationEnabled = true; this._pageSize = 0x100; this._searchOption = null; this._autoRangeRetrieve = true; this._sdFlags = SecurityMasks.Owner | SecurityMasks.Group | SecurityMasks.Dacl; if (sessionInfo == null) { if (obj == null) { this._adSession = ADSession.ConstructSession(null); } else { this._adSession = ADSession.ConstructSession(obj.SessionInfo); } } else { this._adSession = ADSession.ConstructSession(sessionInfo); } if (obj != null) { this._adObject = obj; this._searchRoot = this._adObject.DistinguishedName; foreach (string propertyName in this._adObject.PropertyNames) { this._propertyList.Add(propertyName); } } }
private ADObject CreateRichADObject(ADObject resultEntry) { ADPropertyValueCollection item; ADObject aDObject = new ADObject(); aDObject.DistinguishedName = resultEntry.DistinguishedName; bool flag = false; bool flag1 = false; bool flag2 = false; foreach (string propertyName in resultEntry.PropertyNames) { if (flag || string.Compare(propertyName, "distinguishedName", StringComparison.OrdinalIgnoreCase) != 0) { if (flag1 || string.Compare(propertyName, "objectClass", StringComparison.OrdinalIgnoreCase) != 0) { if (flag2 || string.Compare(propertyName, "objectGUID", StringComparison.OrdinalIgnoreCase) != 0) { if (!this._schemaTranslationEnabled) { aDObject.Add(propertyName, resultEntry[propertyName]); } else { aDObject.Add(propertyName, this._typeConverter.ConvertFromRaw(propertyName, resultEntry[propertyName])); } } else { item = resultEntry[propertyName]; if (item.Count <= 0) { Guid? nullable = null; aDObject.ObjectGuid = nullable; } else { object objectGuidObj = item[0]; if (objectGuidObj is string) { byte[] objGuidBytes = Encoding.Default.GetBytes ((string)objectGuidObj); try { aDObject.ObjectGuid = new Guid?(new Guid(objGuidBytes)); } catch { aDObject.ObjectGuid = null; } } else if (objectGuidObj is byte[]) { aDObject.ObjectGuid = new Guid?(new Guid((byte[])item[0])); } else { aDObject.ObjectGuid = null; } } flag2 = true; } } else { item = resultEntry[propertyName]; if (item.Count <= 0) { aDObject.ObjectClass = null; } else { aDObject.ObjectClass = (string)item[item.Count - 1]; aDObject.ObjectTypes = item; } flag1 = true; } } else { flag = true; } } aDObject.IsSearchResult = true; return aDObject; }
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)); } }