Wednesday, January 12, 2011

Logging in as another user in sharepoint

Hi. I'm site collection administrator/(physical server administrator) in SharePoint (3.0), and I'm debugging other users' rights to access some of our own features. Is it possible, in any way, to log in as another user(with his/her rights) without knowing his password? I can create my own 'dummy' user assigned to same groups, but looking in 100+ groups if user is there isn't what I want to do this evening. Thanks.

-- y

  • I don't know of any way to user an account without the password. However, you could just make a copy of the user in AD, this will retain the same group membership, and you can then set the password to whatever you like.

    All you need to do is right click on the user, click copy and then complete the details required.

    Sean Earp : That would work great, assuming the SharePoint permissions are assigned to SharePoint groups containing AD groups (containing the user and cloned user). I have seen many SharePoint installs where the users were added directly to SharePoint groups. Just something to lookout for when troubleshooting permissions in SharePoint :)
    Yossarian : In fact, I 'inherited' crappy system to administrate and develop on, and there are no groups in AD, only in sharepoint, so this isn't solution :(
    From Sam Cogan
  • Short answer - No it is not.

    Long answer - The best practice for this is to set up test user accounts in AD and SharePoint in a logical and structured way and to add this task to Admin processes for adding a new user group. This is the only way you will be able to test properly. And of course these users should really be on your test environment but I realise that a lot of companies are to either tight or stupid or both to fund dev and test environments for SharePoint so you may have to do it in live. It can be a lot of work depending on your environment but it really is the only way to see if "Tony in Marketing" really can't access the Marketing Proposals Library or if he is just a dork.

    Alternative answer: Use remote control software like CoPilot to take over Tony's computer to see the problem first hand

    @_nige MCTS SharePoint

    Yossarian : You're not true, I worked it out.
    Kevin Davis : I work on the SharePoint product team and am responsible for permissions management UI. I'd encourage this approach.
    Yossarian : I'd rather waste my time other way than trying to force our crappy implementations to work, but one evening hacking sharepoint is cheaper than spending one month rewriting our old code.
    Yossarian : (there was no intended offense in previous posts, sorry if it looked like that)
  • You cannot login as another user without password (afaik)

    Some of approaches you might wanna try are described in this article.

    However if you really want to "login" as another user to check particular permissions you might wanna try this product.

  • So. The solution is following: (not clean, but working)

    1) write own IHttpModule, containing:

    class LoginModule {
     public void Init(HttpApplication context)
     {
        context.PreRequestHandlerExecute += new EventHandler(UglyHack);
     }
    
     void UglyHack(object sender, EventArgs e)
     {
         HttpCookie wannabe = (HttpContext.Current.Request.Cookies["_sp_admin_wanna_be_user"]);
         if (wannabe != null && SPContext.Current.Web.CurrentUser.IsSiteAdmin)
         {
             SPWeb cw = SPContext.Current.Web;
             typeof(SPWeb).GetField("m_CurrentUser", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(
             SPContext.Current.Web,
             cw.AllUsers[wannabe.Value]);
         }
     }
    }
    

    2) Sign it

    3) GAC it

    4) to web.config().

    Voila! Youre the man. :) (of course i added logic to add cookie setting to menu, security, etc..)

    From Yossarian
  • Yossairian, could you please your whole solution here?

0 comments:

Post a Comment