web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics SL (Archived)

Using logged user inside a QuickQuery

(0) ShareShare
ReportReport
Posted on by 16

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

I have the same question (0)
  • Erich Strelow F Profile Picture
    16 on at

    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.

  • Verified answer
    Erich Strelow F Profile Picture
    16 on at

    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;
    


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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics SL (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans