Jump to content

Can WinAPI be used via a Linux shell script?


habskilla

Recommended Posts

Hi Habskilla,

 

Sorry, the WinAPI (Windows API) can only be called from Windows Machines using PowerShell. With the use of PowerShell, you can execute the script under the identity of an Active Directory account, which then gives you the same level of access as if you were logged into Passwordstate.

For Linux machines, you will need to use the standard API, which used API Keys for authentication.

Regards

Click Studios

Link to comment
Share on other sites

Hi Guys,

 

Interesting - didn't know that was even in the works.
 

With PowerShell and our WinAPI, it is the parameter -UseDefaultCredentials which is used to pass the identity of the authenticated "Windows" account across to our API - basically it's impersonation. I'm not sure, but I don't think PowerShell Core can support this, as you're not logged on as a Windows User - unless there's a way to do this in Linux.

Regards

Click Studios

Link to comment
Share on other sites

You can also save your credentials in a variable ($credVariabke = Get-Credentials) and pass this to the Invoke-Rest Powershell command. So I assume, there could be a way.

I also can imagine, that you could pass your credential to a REST-call header from another system (e.g. bash script) to authenticate, but I'm not familiar with bash scripts. 

Link to comment
Share on other sites

  • 4 months later...

Hi,

 

i would not say that you can use WinApi only from windows machines. We are using WinApi from Linux machines for quite some time and it works fine :) as simple as this:

curl  --ntlm  -u "user:pass" "https://passwordstate_url/winapi/passwords/XX"

 

Link to comment
Share on other sites

  • 2 weeks later...

Hi Habskilla

 

To create the REST JSON Body I always go for the following approach: First create a PowerShell object and convert it then to a JSON-String. The big advantage of that is, that you don't have to care about any special characters, escaping and stuff like that.

$Body = @{
     FolderName = $Name
     Description = $Description
	 NestUnderFolderID = $ParentFolderID
	 APIKey = $global:PasswordStateSystemWideAPIKey
}
$jsonBody = $Body | ConvertTo-Json
$PasswordstateURLFull = "$($global:PasswordstateURL)/api/folders"
$result = Invoke-Restmethod -Method POST -Uri $PasswordstateURLFull -ContentType "application/json; charset=utf-8" -Body $jsonBody

The response I get is then stored in $result and can be accessed directly:

$output = $result.FolderID

If you have the answer as a string you also could use for the following approach:

$responseObject = $responseJsonString | ConvertFrom-Json

If you take a look the KeePassImport-Script you'll find some more examples.

 

All the best,

 

Fabian

Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...