Menu

Running as a different user

2010-09-21
2013-06-12
  • Marko Bozikovic

    Marko Bozikovic - 2010-09-21

    Hi all,

    I'm close to finishing support for running tabs under different user and I'd like a bit of input.

    Configuring username

    Currently, I have simply added a username edit box to tab configuration. If there's something entered, upon opening that tab, you will be asked for user credentials. You can both change the username and enter the password.

    Other available options are:
    1. instead of just an edit box, add a check box, so that the username edit box can be left empty. This way, the user will have to provide both username and password each time they open that tab.

    2. Provide another submenu for starting any tab under different credentials.

    Title formatting

    Currently, tab title is formatted like this: [username title

    Do you have any other ideas?

    Cheers,

    Marko

     
  • chrisz

    chrisz - 2010-09-25

    Hi,

    I tried your commit.and it seems it does not work on VISTA.
    You cannot use LoadUserProfile. (acces denied or missing privileges)
    You cannot specify an environment block and specify LOGON_WITH_PROFILE. (error 1783)
    You must use Impersonation to access to the env of the user before CreateProcessWithLogonW.

    I wrote a workaround in git@github.com:cbucher/console.git.

    Cheers,

    Chrisz

     
  • Kirill

    Kirill - 2010-09-27

    Marko,

    my 2 cents: I think the title will work (seems like MS does exactly that).

    As of the user name, I'd go for a checkbox because "empty textbox" was always hard for me to understand - does whitespace count? if not, what if I have whitespace in my user name?
    And the Run As… menu item is probably difficult to present nicely. I mean right-click on a menu item that pops up a context menu with two commands - Open and Run As… - is nice, but I always thought it's difficult to implement.

    • Kirill.
     
  • Marko Bozikovic

    Marko Bozikovic - 2010-09-28

    Chrisz,

    The reason I used LoadUserProfile is that on WinXP, CreateEnvironmentBlock doesn't work properly if LoadUserProfile has not been called previously.

    I need to call CreateEnvironmentBlock in order to get other user's COMSPEC variable. Calling ImpersonateLoggedOnUser and GetEnvironmentVariable does not work.

    I see no other way to get the other user's COMSPEC variable.

    Kirill,

    I agree with you on the checkbox observation, I will add it. As for the menu, I was thinking about adding another menu (e.g. 'Run As…' or 'Open Tab as…')

    Cheers,

    Marko

     
  • Marko Bozikovic

    Marko Bozikovic - 2010-09-28

    I can't seem to find a reliable way to get another user's environment variables under all circumstances (OS version, current user's account type, etc)

    Until I do, I suggest that if a shell is not explicitly defined for a tab, we start cmd.exe instead of other user's comspec shell.

    Cheers,

    Marko

     
  • Kirill

    Kirill - 2010-09-28

    Marko,

    I think your solution is fine for now - it will probably cover more than 80% of users.

    > As for the menu, I was thinking about adding another menu (e.g. 'Run As…' or 'Open Tab as…')
    I don't see it and am very sorry about that. Do you mean that I'll have to select Open Tab as… menu item and then select the tab from a dialog? If so, I'm not quite excited. Or do you mean that Open Tab as… menu will have sub-menus (similar to New Tab item)? If so, it will make "groups of tabs" difficult to implement. Do you want me to look into menu item's context menu?

    • Kirill.
     
  • Marko Bozikovic

    Marko Bozikovic - 2010-09-28

    Kiril,

    I was thinking of a new submenu, just like 'New Tab' submenu.

    Another cool idea is to make each tab menu entry a drop down button, like we have it on the toolbar for the 'New tab' command. Clicking on the item would execute the default command (open tab), clicking on the down arrow would open a submenu with Open and Open as user… commands. However, I'm not sure if that's possible.

    I don't think that menu items' context menus are a way to go (even if they're possible)

    Cheers,

    Marko

     
  • Kirill

    Kirill - 2010-09-28

    Marko,

    menu item with a drop down is possible (I believe it's called "owner draw" item), but new sub-menu is definitely easier.

    On the other hand, I think just one method would be enough - either checkbox in the tab configuration or "games" with the menu items. If we ever implement "groups of tabs", one can have all "elevated" tabs in one group and all regular tabs in another.

    Frankly, I'm more interested in getting your "elevated tabs" code in more or less stable condition, so I can rebase my branches. Therefore, I'd add the checkbox on the tab configuration tab and forget about menus for the moment [just to satisfy some "pushy" contributor :)

    • Kirill.
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.