/// <summary> /// Displays the Directory Object Picker (Active Directory) common dialog, when called by ShowDialog. /// </summary> /// <param name="hwndOwner">Handle to the window that owns the dialog.</param> /// <returns>If the user clicks the OK button of the Directory Object Picker dialog that is displayed, true is returned; /// otherwise, false.</returns> protected override bool RunDialog(IntPtr hwndOwner) { IDsObjectPicker ipicker = Initialize(); if (ipicker == null) { selectedObjects = null; return(false); } try { IDataObject dataObj = null; int hresult = ipicker.InvokeDialog(hwndOwner, out dataObj); if (hresult == HRESULT.S_OK) { selectedObjects = ProcessSelections(dataObj); Marshal.ReleaseComObject(dataObj); return(true); } if (hresult == HRESULT.S_FALSE) { selectedObjects = null; return(false); } throw new COMException("IDsObjectPicker.InvokeDialog failed", hresult); } finally { Marshal.ReleaseComObject(ipicker); } }
/// <summary> /// Displays the Directory Object Picker (Active Directory) common dialog, when called by ShowDialog. /// </summary> /// <param name="hwndOwner">Handle to the window that owns the dialog.</param> /// <returns>If the user clicks the OK button of the Directory Object Picker dialog that is displayed, true is returned; /// otherwise, false.</returns> protected override bool RunDialog(IntPtr hwndOwner) { IDataObject dataObj = null; IDsObjectPicker ipicker = Initialize(); if (ipicker == null) { selectedObjects = null; return(false); } int hresult = ipicker.InvokeDialog(hwndOwner, out dataObj); selectedObjects = ProcessSelections(dataObj); return(hresult == HRESULT.S_OK); }
/// <summary> /// When overridden in a derived class, specifies a common dialog box. /// </summary> /// <param name="hwndOwner">A value that represents the window handle of the owner window for the common dialog box.</param> /// <returns> /// true if the dialog box was successfully run; otherwise, false. /// </returns> protected override bool RunDialog(IntPtr hwndOwner) { IDsObjectPicker iPicker = null; try { iPicker = InitializeObjectPicker(); System.Runtime.InteropServices.ComTypes.IDataObject dataObj = null; iPicker.InvokeDialog(hwndOwner, out dataObj); this.selectedObjects = ProcessSelections(dataObj); return(selectedObjects.Count > 0); } finally { iPicker = null; } }
public ADObject[] ShowObjectPicker(IntPtr parentHandle) { using (logX.loggerX.InfoCall()) { packLPArray packedAttributeList = null; DSOP_SCOPE_INIT_INFO[] scopeInitInfo = new DSOP_SCOPE_INIT_INFO[2]; DSObjectPicker picker = new DSObjectPicker(); DSOP_INIT_INFO initInfo = new DSOP_INIT_INFO(); IDataObject dataObj = null; logX.loggerX.Debug("Initialize AD Picker"); IDsObjectPicker ipicker = Initialize(ref picker, ref packedAttributeList, ref scopeInitInfo, ref initInfo); logX.loggerX.Debug("Invoke AD Picker Dialog"); ipicker.InvokeDialog(parentHandle, out dataObj); return(ProcessSelections(dataObj)); } }