Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
        }