private void StackPanel_Checked(object sender, RoutedEventArgs e) { CheckBox c = sender as CheckBox; ActiveDirectoryObject ado = (ActiveDirectoryObject)Enum.Parse(typeof(ActiveDirectoryObject), c.Tag.ToString()); OnCheckActiveDirectoryObject((bool)c.IsChecked, ado); }
private void ActiveDirectory_OnCheckActiveDirectoryObject(bool IsCheck, ActiveDirectoryObject ado) { switch (ado) { case ActiveDirectoryObject.Computers: //SetActiveDirectoryObjectComputers(IsCheck); break; case ActiveDirectoryObject.Printers: SetActiveDirectoryObjectPrinters(IsCheck); break; default: break; } }
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; }
/// <summary> /// Moves and / or renames an object in Active Directory. /// </summary> /// <param name="objectGuid">The GUID of the object to move and / or rename.</param> /// <param name="newParentObjectGuid">(Optional: Required only if moving) The GUID of the new parent object for the object (if moving).</param> /// <param name="newCommonName">(Optional: Required only if renaming) The new common name (if renaming).</param> /// <returns>True if the object was moved or renamed, false otherwise.</returns> public bool MoveRenameObject(Guid objectGuid, Guid? newParentObjectGuid = null, string newCommonName = null) { if (objectGuid != Guid.Empty) { // Get the object that corresponds with the GUID supplied. try { ActiveDirectoryObject obj = new ActiveDirectoryObject(this, objectGuid); ActiveDirectoryObject parentObj; if (newParentObjectGuid != null && newParentObjectGuid != Guid.Empty) { // We're moving. parentObj = new ActiveDirectoryObject(this, newParentObjectGuid.Value); } else { // Set the parent object to the current parent of the object supplied. parentObj = new ActiveDirectoryObject(this, GetGUIDByDistinguishedName(obj.OrganizationalUnit)); } string commonName; if (!string.IsNullOrWhiteSpace(newCommonName)) { // We're renaming the object. commonName = newCommonName; } else { // Set the common name to the object's existing common name. commonName = obj.CommonName; } // Move and / or rename the object in Active Directory. return ldap.MoveRenameEntry(obj.DistinguishedName, parentObj.DistinguishedName, "CN=" + commonName); } catch { } } return false; }