Ejemplo n.º 1
0
        private void ExportUsingGroupsOfUser(PwDatabase database, PwGroup selectedGroup)
        {
            //if the menu was called from a GroupsGroup we try to find all users in that group and then export
            //the pwds for all of them.
            PwGroup groupsGroup = database.GetGroupsGroup();

            if (selectedGroup == groupsGroup || selectedGroup.IsInsideParent(groupsGroup))
            {
                foreach (PwEntry entry in selectedGroup.GetEntries(true))
                {
                    if (database.IsUserProxy(entry))
                    {
                        Export(database, database.GetProxyTargetFor(entry));
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public static bool IsPasswordProxy(this PwDatabase database, PwEntry entry)
 {
     return(entry.IsProxyNode() && !database.IsUserProxy(entry));
 }
Ejemplo n.º 3
0
        private Changes FixHomeFolders()
        {
            //====================================
            //maybe we have some emptyFolders => new homefolders!
            //we can use the same loop to test for illegal shares of
            //foreign homes. that means, a foreign proxy is located
            //in a users homefolder.
            PwGroup usersGroup = m_database.GetUsersGroup();
            PwObjectList <PwGroup> allHomes     = usersGroup.GetGroups(false);
            PwObjectList <PwGroup> foreignHomes = new PwObjectList <PwGroup>();
            PwObjectList <PwGroup> emptyHomes   = new PwObjectList <PwGroup>();

            foreach (PwGroup home in allHomes)
            {
                //we remember the empty folders, so we can later make them new users
                if (home.Entries.UCount == 0)
                {
                    emptyHomes.Add(home);
                }
                //if we have more than 1 entry in a homegroup we have to check for
                //possible foreign shares
                if (home.Entries.UCount > 1)
                {
                    List <PwEntry> entries = home.GetEntries(false).CloneShallowToList();
                    foreach (PwEntry entry in entries)
                    {
                        //is it a userPorxy or a pwdProxy?
                        //the first we have to remove but the second one
                        //is a note that we want to share a pwd with this user,
                        //so we don't touch it!
                        if (m_database.IsUserProxy(entry))
                        {
                            entry.DeleteFrom(home, m_database);
                        }
                    }
                }
                //and maybe we have a foreign home in our homefolder (to share it..)
                //so we have to fix that too.
                foreach (PwGroup foreignHome in home.GetGroups(true))
                {
                    if (foreignHome.IsHome())
                    {
                        foreignHomes.Add(foreignHome);
                    }
                }
            }
            Changes changeFlag = Changes.None;

            foreach (PwGroup home in emptyHomes)
            {
                string userName = home.Name;

                try {
                    changeFlag |= CreateNewUser(userName, home);
                }
                catch (Exception) {
                    // WTF: Why?
                    //should throw the exception and later inform the user...
                }
            }
            foreach (PwGroup home in foreignHomes)
            {
                home.MoveToParent(m_database.GetUsersGroup());
                changeFlag |= Changes.GroupMoved;
            }
            return(changeFlag);
        }