Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics SL (Archived)

Using logged user inside a QuickQuery

Posted on by 1,642

Are there any hints on how to use the current userid value inside a QuickQuery view?

I've been trying to use the PES table, but I don't really understand how it works.

I'm setting up a view using the built in SQL funcions like SYSTEM_USER and CURRENT_USER. I'm using a Windows based authentication scheme, so this should work. I still can't get a working query though.

Thanks in advance.

*This post is locked for comments

  • Verified answer
    Erich Strelow F Profile Picture
    Erich Strelow F 1,642 on at
    RE: Using logged user inside a QuickQuery

    Ok, I finally hacked into it. 

    I never really understood the 07718158D19D4f5f9D23B55DBF5DF1 and E8F575915A2E4897A517779C0DD7CE tweaks. It seems that the QQVIE00.EXE process establish a proper SL environment and then starts an anonymous .Net SqlClient Data Provider session to fetch the data. So, you should be able to locate other SQL processes that are originated from the same client QQVIE00 process, a value available through the host_id() built in function.

    This approach sould work only under some conditions.

    I think this is against Quick Query intended focus. What I need is an outlook grid showing "My transactions" with drill down and excel-export capabilities. Role center should be a contendor for this.

    /*******************************************************************
       xQQ_User()
       
       Returns the Application User currently querying a QQ view
       
       Notes:
       This works for Windows Authentication mode
       
       SL 2011 itself executes the QQ query under an anonymous session.
       This function does a redirection searching for the authenticated 
       user owner of the same QQVIEW00 process in the client
       machine. 
       This should work only under specific scenarios under the SL full 
       client.  
    ********************************************************************/
    create function xQQ_User() returns char(47)
    with execute as  '07718158D19D4f5f9D23B55DBF5DF1'
    as
    begin
    return (
       select userid
       from dbo.vs_userrec
       where WindowsUserAcct = (
          select max(loginame)
          from sys.sysprocesses
          where hostname like HOST_NAME() + '%' and
          hostprocess=host_id() and 
          spid <> @@spid
       )
    ) ;
    end;
    


  • Erich Strelow F Profile Picture
    Erich Strelow F 1,642 on at
    RE: Using logged user inside a QuickQuery

    I am revisiting this issue. It seems that the SQL session that executes the query is always the E8F575915A2E4897A517779C0DD7CE user.  There's no context change and no host information. There is no PES record either.

    So, the QQ execution seems strictly anonymous for the time being.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans