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 static VMDirServerDTO ShowSelectComputerUI() { var ui = new frmConnectToServer(); //ui.txtDirectoryServer.Text = "192.168.2.9:11711"; //ui.txtDirectoryServer.Text = "10.118.72.132:11711"; if (ui.ShowDialog() == DialogResult.OK) { return(ui.ServerDTO); } return(null); }
public void Login() { this.Children.Clear(); try { var frm = new frmConnectToServer(_serverDTO); if (MMCDlgHelper.ShowForm(frm)) { if (_serverDTO.Connection.CreateConnection() == 1) { isLoggedIn = true; this.DisplayName = ServerDTO.Server; if (string.IsNullOrWhiteSpace(_serverDTO.BaseDN)) { ServerDTO.Connection.Search("", LdapScope.SCOPE_BASE, "(objectClass=*)", new string[] { "rootDomainNamingContext" }, 0, delegate(ILdapMessage searchRequest, List <ILdapEntry> entries) { _serverDTO.BaseDN = GetRootDomainNamingContext(entries); }); } else { ServerDTO.Connection.Search(_serverDTO.BaseDN, LdapScope.SCOPE_BASE, "(objectClass=*)", new string[] { "entryDN" }, 0, delegate(ILdapMessage searchRequest, List <ILdapEntry> entries) { }); } if (string.IsNullOrWhiteSpace(_serverDTO.BaseDN)) { throw new Exception("Failed to retrieve base dn."); } this.Children.Add(new DirectoryNode(_serverDTO.BaseDN, ServerDTO)); LoggedInServerActions(); } else { throw new Exception("Invalid credentials or server is not reachable!"); } } } catch (Exception exp) { _serverDTO.Connection = null; MMCDlgHelper.ShowException(exp); } }