Beispiel #1
0
        /// <summary>
        /// On Selection Changed
        /// </summary>
        protected override void OnSelectionChanged()
        {
            string currentPath = this.Filename;

            if (copyDir != null)
            {
                currentPath += "/" + copyDir;
            }

            try
            {
                if (ifws.CanBeiFolder(currentPath))
                {
                    this.SetResponseSensitive(ResponseType.Ok, true);
                }
                else
                {
                    this.SetResponseSensitive(ResponseType.Ok, false);
                }
            }
            catch (Exception)
            {
                this.SetResponseSensitive(ResponseType.Ok, false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Checks to see if a path can become an iFolder.
        /// </summary>
        /// <param name="path">The path that is tested.</param>
        /// <returns>The method returns <b>true</b> if the specified path can become an ifolder; otherwise, <b>false</b>.</returns>
        public bool CanBeiFolder([MarshalAs(UnmanagedType.LPWStr)] string path)
        {
            try
            {
                // Make sure the user has read/write access to the directory.
                if (Win32Security.AccessAllowed(path))
                {
                    connectToWebService();
                    if (ifWebService != null)
                    {
                        return(ifWebService.CanBeiFolder(path));
                    }
                }
            }
            catch (WebException e)
            {
                ifWebService = null;
                if (e.Status == WebExceptionStatus.ProtocolError)
                {
                    LocalService.ClearCredentials();
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Caught exception - " + e.Message);
            }

            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// Method that performs migration..
        /// </summary>
        public bool MigrateFolder()
        {
            /*
             * Check if the destination folder can be an iFolder
             * Copy the folder if needed
             * If yes create the iFolder, else stay at the same page
             * if the folder is to be removed from 2.x domain remove.
             */
            DomainItem domain = this.MigrationIdentityPage.domain;
            bool       shared = this.MigrationIdentityPage.SSL;
            string     encryptionAlgorithm = this.MigrationIdentityPage.Encrypion? "BlowFish" : "";
            string     destination;

            // Migration Option is true if the folder is to be removed from 2.x domain
            try
            {
                if (this.MigrationServerPage.MigrationOption == false)
                {
                    destination = this.MigrationServerPage.HomeLocation;
                    DirectoryInfo dir = new DirectoryInfo(destination);
                    if (dir.Exists == false)
                    {
                        this.verifyPage.CloseWaitDialog();
                        MessageBox.Show(Resource.GetString("ErrDirCreate"));
                        return(false);
                    }

                    // Create the ifolder directory
                    if (this.MigrationServerPage.CopyParentDirectory)
                    {
                        DirectoryInfo di = new DirectoryInfo(this.location);
                        destination = destination + "\\" + di.Name;
                        di          = new DirectoryInfo(destination);
                        if (di.Exists)
                        {
                            this.verifyPage.CloseWaitDialog();
                            MessageBox.Show(Resource.GetString("DirExists") /*"The directory exists already"*/, Resource.GetString("MigrationTitle"), MessageBoxButtons.OK);
                            return(false);
                        }
                        else
                        {
                            try
                            {
                                di.Create();
                            }
                            catch (Exception ex)
                            {
                                this.verifyPage.CloseWaitDialog();
                                MessageBox.Show(ex.ToString(), Resource.GetString("ErrDirCreate"), MessageBoxButtons.OK);
                                return(false);
                            }
                        }
                    }
                    //Check that the final path is already 3.6 ifolder, we don't do a 2.x check here
                    if (ifws.CanBeiFolder(destination) == false)
                    {
                        this.verifyPage.CloseWaitDialog();
                        MessageBox.Show(Resource.GetString("CannotBeiFolder") /*"The folder can not be converted into ifolder"*/, Resource.GetString("MigrationTitle") /*"Error creating iFolder"*/, MessageBoxButtons.OK);
                        return(false);                        // can't be an iFolder
                    }

                    // Copy the contents
                    if (!CopyDirectory(new DirectoryInfo(location), new DirectoryInfo(destination)))
                    {
                        this.verifyPage.CloseWaitDialog();
                        MessageBox.Show(Resource.GetString("CannotCopy") /*"Unable to copy the folder"*/, Resource.GetString("MigrationTitle") /*"Error copying the folder"*/, MessageBoxButtons.OK);
                        return(false);                          // unable to copy..
                    }
                }
                else
                {
                    destination = this.location;
                    if (ifws.CanBeiFolder(destination) == false)                        // Display a message box
                    {
                        this.verifyPage.CloseWaitDialog();
                        MessageBox.Show(Resource.GetString("CannotBeiFolder") /*"The folder can not be converted into ifolder"*/, Resource.GetString("MigrationTitle") /*"Error creating iFolder"*/, MessageBoxButtons.OK);
                        return(false);                        // can't be an iFolder
                    }
                }

                if (shared)
                {
                    if (ifws.CreateiFolderInDomain(destination, domain.ID) == null)
                    {
                        this.verifyPage.CloseWaitDialog();
                        MessageBox.Show(Resource.GetString("MigrationConvert") /*Unable to convert to an iFolder*/, Resource.GetString("MigrationTitle") /*"Error creating iFolder"*/, MessageBoxButtons.OK);
                        return(false);
                    }
                }
                else
                {
                    string passphrase = this.simiasWebService.GetPassPhrase(this.identityPage.domain.ID);
                    if (ifws.CreateiFolderInDomainEncr(destination, domain.ID, false, encryptionAlgorithm, passphrase) == null)
                    {
                        this.verifyPage.CloseWaitDialog();
                        MessageBox.Show(Resource.GetString("MigrationConvert") /*Unable to convert to an iFolder*/, Resource.GetString("MigrationTitle") /*"Error creating iFolder"*/, MessageBoxButtons.OK);
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                this.verifyPage.CloseWaitDialog();
                MessageBox.Show(Resource.GetString("CannotBeiFolder") /*"The folder can not be converted into ifolder"*/, Resource.GetString("MigrationTitle") /*"Error creating iFolder"*/, MessageBoxButtons.OK);
                return(false);
            }

            if (this.MigrationServerPage.MigrationOption == true)
            {
                //remove the 2.x registry entry for the migarted (not copy) ifolder
                string      iFolderRegistryKey = @"Software\Novell iFolder";
                RegistryKey iFolderKey         = Registry.LocalMachine.OpenSubKey(iFolderRegistryKey, true);
                try
                {
                    iFolderKey.DeleteSubKeyTree(UserName);
                }
                catch (Exception ex)
                {
                    this.verifyPage.CloseWaitDialog();
                    Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(ex.Message, Resource.GetString("MigrationTitle"), "", MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                    mmb.ShowDialog();
                    mmb.Close();
                }
            }
            return(true);
        }