Example #1
0
        ///<summary>
        /// Display passphrase dialog
        ///</summary>
        ///<param name="path">Path of ifolder</param>
        ///<param name="domain_id">Id of the domain</param>
        ///<param name="encrypted">Enctypred or not</param>
        ///<returns>0 on success else 1</returns>
        private static int ShowPassPhraseDialog(string path, string domain_id, bool encrypted)
        {
            Console.WriteLine(" The corresponding c# file is called");
            if (!encrypted)
            {
                iFolderWeb newiFolder = ifws.CreateiFolderInDomain(path, domain_id);
                if (newiFolder != null)
                {
                    Console.WriteLine("Created iFolder");
                    return(0);
                }
                Console.WriteLine("Error creating iFolder");
                return(1);
            }
            bool passphraseSet = false;

            try
            {
                passphraseSet = simws.IsPassPhraseSet(domain_id);
            }
            catch (Exception ex)
            {
                // Unable to create iFolder. Need to login..
            }
            bool passPhraseEntered = false;

            if (passphraseSet == true)
            {
                bool   rememberOption = simws.GetRememberOption(domain_id);
                string passphrasecheck;
                passphrasecheck = simws.GetPassPhrase(domain_id);
                if (passphrasecheck == null || passphrasecheck == "")
                {
                    passPhraseEntered = ShowVerifyDialog(domain_id, simws);
                }
                else
                {
                    passPhraseEntered = true;
                }
            }
            else
            {
                passPhraseEntered = ShowEnterPassPhraseDialog(domain_id, simws);
            }
            if (passPhraseEntered == true)
            {
                iFolderWeb newiFolder = ifws.CreateiFolderInDomainEncr(path, domain_id, !encrypted, "BlowFish", simws.GetPassPhrase(domain_id));
                if (newiFolder != null)
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }
//			string[] array = domainController.GetRAList( domain_id);
            return(0);
        }
Example #2
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);
        }