Error running PowerQuery in Linux - fixme:security:ImpersonateLoggedOnUser

Questions about Wine on Linux
Locked
gratefulguest
Newbie
Newbie
Posts: 1
Joined: Wed May 15, 2024 8:55 pm

Error running PowerQuery in Linux - fixme:security:ImpersonateLoggedOnUser

Post by gratefulguest »

Hello all, I'm appreciative of any help/direction on this.

My ambition is to run the Microsoft PowerQuery (PQ) SDK within Linux (eventually hooking into Python). I've made good progress -- initialised the extension and set a credential using their EXEs. However when trying to run the connector I'm getting an error "Couldn't impersonate token" which appears related to a "ImpersonateLoggedOnUser" function.

My setup is using the latest scottyhardy/docker-wine image. I then run (using a non-root user):

Download PowerQuery SDK Tools package:

Code: Select all

wget https://www.nuget.org/api/v2/package/Microsoft.PowerQuery.SdkTools/2.127.3 -O Microsoft.PowerQuery.SdkTools.2.127.3.nupkg.zip \
    && unzip Microsoft.PowerQuery.SdkTools.2.127.3.nupkg.zip -d Microsoft.PowerQuery.SdkTools.2.127.3.nupkg
Set up PQ files

Code: Select all

echo '// This file contains your Data Connector logic
[Version = "0.1.0"]
section PowerQueryPython;

[DataSource.Kind="PowerQueryPython", Publish="PowerQueryPython.Publish"]
shared PowerQueryPython.Contents = (optional message as text) =>
    let
        _message = if (message <> null) then message else "(no message)",
        a = "Hello from PowerQueryPython: " & _message
    in
        a;

// Data Source Kind description
PowerQueryPython = [
    Authentication = [
        // Key = [],
        // UsernamePassword = [],
        // Windows = [],
        Anonymous = []
    ]
];

// Data Source UI publishing description
PowerQueryPython.Publish = [
    Beta = true,
    Category = "Other",
    ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
    LearnMoreUrl = "https://powerbi.microsoft.com/",
    SourceImage = PowerQueryPython.Icons,
    SourceTypeImage = PowerQueryPython.Icons
];

PowerQueryPython.Icons = [];
' > powerquery-python.pq

echo 'let
    Source = Web.BrowserContents("https://en.wikipedia.org/wiki/Lleyton_Hewitt"),
    #"Extracted Table From Html" = Html.Table(Source, {{"Column1", "TABLE.infobox.vcard > * > TR > TD[colspan=""2""]:not([rowspan]):nth-child(1):nth-last-child(1), TABLE.infobox.vcard > * > TR > TH:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(2), TABLE.infobox.vcard > * > TR > TH[colspan=""2""]:not([rowspan]):nth-child(1):nth-last-child(1)"}, {"Column2", "TABLE.infobox.vcard > * > TR > TD[colspan=""2""]:not([rowspan]):nth-child(1):nth-last-child(1), TABLE.infobox.vcard > * > TR > TH:not([colspan]):not([rowspan]):nth-child(1):nth-last-child(2) + TD:not([colspan]):not([rowspan]):nth-child(2):nth-last-child(1), TABLE.infobox.vcard > * > TR > TH[colspan=""2""]:not([rowspan]):nth-child(1):nth-last-child(1)"}}, [RowSelector="TABLE.infobox.vcard > * > TR"]),
    #"Changed Type" = Table.TransformColumnTypes(#"Extracted Table From Html",{{"Column1", type text}, {"Column2", type text}})
in
    #"Changed Type"
' > example.query.pq
Configure wine, initialise connector, and set a credential.

Code: Select all

winecfg

Code: Select all

wine /home/$USERNAME/Microsoft.PowerQuery.SdkTools.2.127.3.nupkg/tools/MakePQX.exe \
    compile --directory . --target powerquery-python

Code: Select all

echo '{"AuthenticationKind":"Anonymous","AuthenticationProperties":{},"PrivacySetting":"None","Permissions":[]}' | \
    wine Microsoft.PowerQuery.SdkTools.2.127.3.nupkg/tools/PQTest.exe set-credential \
    -e powerquery-python.mez -q example.query.pq --prettyPrint 
Last step is to run the example query through PQTest, which is where I hit the error. The error logs are as below.

Code: Select all

wine Microsoft.PowerQuery.SdkTools.2.127.3.nupkg/tools/PQTest.exe run-test -e powerquery-python.mez -q example.query.pq --prettyPrint
0044:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0044:err:winediag:nodrv_CreateWindow L"The explorer process failed to start."
0044:err:systray:initialize_systray Could not create tray window
008c:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
008c:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
008c:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
008c:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0114:fixme:mscoree:parse_supported_runtime sku=L".NETFramework,Version=v4.7.2" not implemented
0114:fixme:mscoree:parse_supported_runtime sku=L".NETFramework,Version=v4.7.2" not implemented
0114:fixme:ntdll:NtQuerySystemInformation info_class SYSTEM_PERFORMANCE_INFORMATION
0114:fixme:nls:GetFileMUIPath stub: 0x10, L"C:\\windows\\system32\\tzres.dll", (null), 00007FFFFE4FD1D0, 00007FFFFF5400A0, 00007FFFFE4FD1D8, 00007FFFFE4FD1C8
0114:fixme:nls:GetFileMUIPath stub: 0x10, L"C:\\windows\\system32\\tzres.dll", (null), 00007FFFFE4FD1D0, 00007FFFFF5400A0, 00007FFFFE4FD1D8, 00007FFFFE4FD1C8
0114:fixme:nls:GetFileMUIPath stub: 0x10, L"C:\\windows\\system32\\tzres.dll", (null), 00007FFFFE4FD1D0, 00007FFFFF5400A0, 00007FFFFE4FD1D8, 00007FFFFE4FD1C8
0114:fixme:ntdll:EtwEventSetInformation (deadbeef, 2, 00007F16F8160430, 37) stub
0114:fixme:ver:GetCurrentPackageId (00007FFFFE4FDAD0 0000000000000000): stub
0114:fixme:security:ImpersonateLoggedOnUser (0000000000000000)
[
  {
    "ActivityId": "cfbc1832-1712-43ae-bfd9-c5ff9ab1f457",
    "DataSourceAnalysis": [
      {
        "Kind": "DataSource",
        "FunctionName": "Web.BrowserContents",
        "DataSource": {
          "Kind": "Web",
          "NormalizedPath": "https://en.wikipedia.org/wiki/Lleyton_Hewitt",
          "Path": "https://en.wikipedia.org/wiki/Lleyton_Hewitt"
        },
        "DataSourceReference": {
          "protocol": "http",
          "address": {
            "url": "https://en.wikipedia.org/wiki/Lleyton_Hewitt"
          },
          "authentication": null,
          "query": null
        }
      }
    ],
    "Details": "Couldn't impersonate token.",
    "EndTime": "2024-05-16T01:54:48.8570809+00:00",
    "Method": "PQTest.RunTest",
    "Name": "example.query.pq",
    "StartTime": "2024-05-16T01:54:48.6894525+00:00",
    "DiagnosticEvents": {},
    "RowCount": 0,
    "Status": "Failed",
    "Type": "PQTest.Expression",
    "Error": {
      "Message": "Couldn't impersonate token."
    }
  }
Could anybody give me some suggestions of how/if this can be overcome? Thank you!
Locked