internal void Login() { this.Nodes.Clear(); try { var frm = new frmConnectToServer(ServerDTO); if (frm.ShowDialog() == DialogResult.OK) { if (ServerDTO.Connection.CreateConnection() == 1) { this.Text = ServerDTO.Server; if (string.IsNullOrWhiteSpace(ServerDTO.BaseDN)) { TextQueryDTO dto = new TextQueryDTO("", LdapScope.SCOPE_BASE, VMDirConstants.SEARCH_ALL_OC, new string[] { VMDirConstants.ATTR_ROOT_DOMAIN_NAMING_CONTEXT }, 0, IntPtr.Zero, 0); try { ServerDTO.Connection.Search(dto, delegate(ILdapMessage searchRequest, List <ILdapEntry> entries) { ServerDTO.BaseDN = GetRootDomainNamingContext(entries); }); } catch (Exception) { throw new Exception(VMDirConstants.ERR_DN_RETRIEVAL); } } else { TextQueryDTO dto = new TextQueryDTO(ServerDTO.BaseDN, LdapScope.SCOPE_BASE, VMDirConstants.SEARCH_ALL_OC, new string[] { VMDirConstants.ATTR_DN }, 0, IntPtr.Zero, 0); ServerDTO.Connection.Search(dto, null); } this.Nodes.Add(new DirectoryExpandableNode(ServerDTO.BaseDN, new List <string>(), ServerDTO, PropertiesCtl)); ServerDTO.IsLoggedIn = true; Expand(); DoSelect(); } else { throw new Exception(CommonConstants.INVALID_CREDENTIAL); } } } catch (Exception exp) { ServerDTO.Connection = null; VMDirEnvironment.Instance.Logger.LogException(exp); MiscUtilsService.ShowError(exp); } }
public void FillProperties() { UIErrorHelper.CheckedExec(delegate { TextQueryDTO dto = new TextQueryDTO(Dn, LdapScope.SCOPE_BASE, VMDirConstants.SEARCH_ALL_OC, null, 0, IntPtr.Zero, 0); ServerDTO.Connection.Search(dto, (l, e) => { if(e.Count>0) _properties = ServerDTO.Connection.GetEntryProperties(e[0]); }); }); }
private void GetOperationalAttribute() { TextQueryDTO dto = new TextQueryDTO(_dn, LdapScope.SCOPE_BASE, VMDirConstants.SEARCH_ALL_OC, new string[] { "+" }, 0, IntPtr.Zero, 0); var operationalProperties = new Dictionary <string, VMDirAttributeDTO>(); _serverDTO.Connection.Search(dto, (l, e) => { if (e.Count > 0) { operationalProperties = _serverDTO.Connection.GetEntryProperties(e[0]); } }); _oprAttrDTOList = VmdirUtil.Utilities.ConvertToAttributeDTOList(operationalProperties); }
private void FillProperties() { MiscUtilsService.CheckedExec(delegate { TextQueryDTO dto = new TextQueryDTO(VMDirConstants.ATTR_VMW_DSEROOT_DN, LdapScope.SCOPE_BASE, VMDirConstants.SEARCH_ALL_OC, null, 0, IntPtr.Zero, 0); ServerDTO.Connection.Search(dto, (l, e) => { if (e.Count > 0) { _properties = ServerDTO.Connection.GetEntryProperties(e[0]); } }); }); }
public static List <string> GetObjectClassList(VMDirServerDTO ServerDTO, string searchBase, LdapScope searchScope) { QueryDTO qdto = new TextQueryDTO(searchBase, searchScope, VMDirConstants.SEARCH_ALL_OC, null, 0, IntPtr.Zero, 0); var ocList = new List <string>(); ServerDTO.Connection.Search(qdto, (l, e) => { if (e.Count > 0) { ocList = new List <string>(e[0].getAttributeValues(VMDirConstants.ATTR_OBJECT_CLASS).Select(x => x.StringValue).ToArray()); } }); return(ocList); }
public void ReloadData() { TextQueryDTO dto = new TextQueryDTO(dn, LdapScope.SCOPE_BASE, VMDirConstants.SEARCH_ALL_OC, null, 0, IntPtr.Zero, 0); serverDTO.Connection.Search(dto, (l, e) => { if (e.Count > 0) { dn = e[0].getDN(); properties = serverDTO.Connection.GetEntryProperties(e[0]); } }); FillData(); }
public void RefreshPropertiesView() { ClearData(); _properties.Clear(); ClearContext(); MiscUtilsService.CheckedExec(delegate { TextQueryDTO dto = new TextQueryDTO(_dn, LdapScope.SCOPE_BASE, VMDirConstants.SEARCH_ALL_OC, null, 0, IntPtr.Zero, 0); _serverDTO.Connection.Search(dto, (l, e) => { if (e.Count > 0) { _properties = _serverDTO.Connection.GetEntryProperties(e[0]); } }); }); GetData(); FillListView(); }
private QueryDTO GetQuery() { QueryDTO qdto = null; var lst = new HashSet <string>(_attrToReturnDs.attrList); lst.Add(VMDirConstants.ATTR_OBJECT_CLASS); lst.Add(VMDirConstants.ATTR_DN); if (SearchQueryTabView.IndexOf(SearchQueryTabView.Selected) == 0) { qdto = new BuildQueryDTO(SearchBaseTextField.StringValue, (LdapScope)(int)SearchScopeComboBox.SelectedIndex, (LogicalOp)(int)BfOperatorComboBox.SelectedIndex, _searchCondDs.condList, lst.ToArray(), 0, IntPtr.Zero, 0); } else if (SearchQueryTabView.IndexOf(SearchQueryTabView.Selected) == 1) { qdto = new TextQueryDTO(SearchBaseTextField.StringValue, (LdapScope)(int)SearchScopeComboBox.SelectedIndex, TfSearchFilterTextView.Value, lst.ToArray(), 0, IntPtr.Zero, 0); } return(qdto); }