Exemplo n.º 1
0
		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;
			}
		}
Exemplo n.º 2
0
		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);
			}
		}
Exemplo n.º 3
0
		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;
			}
		}
Exemplo n.º 4
0
		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");
			}
		}
Exemplo n.º 5
0
		public ADDirectoryServer(ADObject identity)
		{
			if (identity != null)
			{
				base.Identity = identity;
				if (identity.IsSearchResult)
				{
					base.SessionInfo = identity.SessionInfo;
				}
				return;
			}
			else
			{
				throw new ArgumentException("identity");
			}
		}
Exemplo n.º 6
0
		public ADPartition(ADObject adobject)
		{
			if (adobject != null)
			{
				base.Identity = adobject;
				if (adobject.IsSearchResult)
				{
					base.SessionInfo = adobject.SessionInfo;
				}
				return;
			}
			else
			{
				throw new ArgumentException("adobject");
			}
		}
Exemplo n.º 7
0
		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");
			}
		}
Exemplo n.º 8
0
		public ADCentralAccessRule(ADObject identity)
		{
			base.Identity = identity;
		}
Exemplo n.º 9
0
		public ADClaimTypeBase(ADObject identity)
		{
			base.Identity = identity;
		}
 public ADResourcePropertyValueType(ADObject identity)
 {
     base.Identity = identity;
 }
Exemplo n.º 11
0
		public ADDomainController(ADObject identity) : base(identity)
		{
		}
Exemplo n.º 12
0
		public ADReplicationConnection(ADObject identity)
		{
			base.Identity = identity;
		}
Exemplo n.º 13
0
 public ADDomainController(ADObject identity) : base(identity)
 {
 }
Exemplo n.º 14
0
 public ADAccount(ADObject identity) : base(identity)
 {
 }
Exemplo n.º 15
0
 public ADUser(ADObject identity) : base(identity)
 {
 }
Exemplo n.º 16
0
 public ADReplicationConnection(ADObject identity)
 {
     base.Identity = identity;
 }
Exemplo n.º 17
0
 public ADComputer(ADObject identity) : base(identity)
 {
 }
Exemplo n.º 18
0
 public ADNtdsSetting(ADObject identity)
 {
     base.Identity = identity;
 }
Exemplo n.º 19
0
 public ADReplicationSubnet(ADObject identity)
 {
     base.Identity = identity;
 }
Exemplo n.º 20
0
 public ADGroup(ADObject identity) : base(identity)
 {
 }
Exemplo n.º 21
0
 public ADTrust(ADObject identity)
 {
     base.Identity = identity;
 }
Exemplo n.º 22
0
		public ADGroup(ADObject identity) : base(identity)
		{
		}
Exemplo n.º 23
0
		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;
			}
		}
Exemplo n.º 24
0
		public ADUser(ADObject identity) : base(identity)
		{
		}
Exemplo n.º 25
0
		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;
			}
		}
Exemplo n.º 26
0
		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);
					}
				}
			}
		}
Exemplo n.º 27
0
		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;
		}
Exemplo n.º 28
0
		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;
				}
			}
		}
Exemplo n.º 29
0
		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;
			}
		}
Exemplo n.º 30
0
		public ADResourcePropertyList(ADObject identity)
		{
			base.Identity = identity;
		}
Exemplo n.º 31
0
		public ADAccount(ADObject identity) : base(identity)
		{
		}
Exemplo n.º 32
0
        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;
        }
Exemplo n.º 33
0
		public ADOrganizationalUnit(ADObject identity)
		{
			if (identity != null)
			{
				base.Identity = identity;
				if (identity.IsSearchResult)
				{
					base.SessionInfo = identity.SessionInfo;
				}
				return;
			}
			else
			{
				throw new ArgumentException("identity");
			}
		}
Exemplo n.º 34
0
 public ADCentralAccessPolicy(ADObject identity)
 {
     base.Identity = identity;
 }
Exemplo n.º 35
0
		public ADClaimTransformPolicy(ADObject identity)
		{
			base.Identity = identity;
		}
Exemplo n.º 36
0
 public ADServiceAccount(ADObject identity) : base(identity)
 {
 }
Exemplo n.º 37
0
        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);
        }
Exemplo n.º 38
0
		public ADSchemaObject(ADObject identity)
		{
			base.Identity = identity;
		}
Exemplo n.º 39
0
		public ADCentralAccessPolicy(ADObject identity)
		{
			base.Identity = identity;
		}
Exemplo n.º 40
0
 public ADClaimTypeBase(ADObject identity)
 {
     base.Identity = identity;
 }
Exemplo n.º 41
0
 public ADCentralAccessRule(ADObject identity)
 {
     base.Identity = identity;
 }
Exemplo n.º 42
0
 public ADReplicationSiteLink(ADObject identity)
 {
     base.Identity = identity;
 }
Exemplo n.º 43
0
 public ADSchemaObject(ADObject identity)
 {
     base.Identity = identity;
 }
Exemplo n.º 44
0
 public ADObjectSearcher(ADObject obj) : this(null, obj)
 {
 }
Exemplo n.º 45
0
		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;
		}
Exemplo n.º 46
0
        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);
                    }
                }
            }
        }
Exemplo n.º 47
0
		public ADObjectSearcher(ADObject obj) : this(null, obj)
		{
		}
Exemplo n.º 48
0
		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);
				}
			}
		}
Exemplo n.º 49
0
		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;
		}
Exemplo n.º 50
0
		public ADReplicationSubnet(ADObject identity)
		{
			base.Identity = identity;
		}
Exemplo n.º 51
0
        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));
            }
        }