RDMDatasource cmdlets not working

Implemented

RDMDatasource cmdlets not working

avatar

Hi, we have installed the latest version of Devolutions.Powershell (2023.1.0.4) and PS version 7.2.9.

Running Get-RDMDatasource results in this:

<14:42:31 30/03/23> PS D:\RBAGit\win-rbhr-powershell> get-rdmdatasource

ID : e01aee5a-4d6e-4bb1-bf07-f5356c6485e4
IsConnected : False
IsOffline : False
Name : Local Data Source
Type : SQLite

ID : 2a2f67a7-c3ae-4821-8174-a4fedbd8d35b
IsConnected : False
IsOffline : False
Name : TEST
Type : SQLServer

But when trying to do this:

$se = Get-RDMDataSource -Name "test"
Set-RDMCurrentDataSource $se

I get an error:
The type initializer for 'NetSecurityNative' threw an exception.
at Interop.NetSecurityNative.ImportPrincipalName(Status& minorStatus, String inputName, Int32 inputNameByteCount, SafeGssNameHandle& outputName)
at Microsoft.Win32.SafeHandles.SafeGssNameHandle.CreatePrincipal(String name)
at System.Net.Security.SafeDeleteNegoContext..ctor(SafeFreeNegoCredentials credential, String targetName)
at System.Net.Security.NegotiateStreamPal.EstablishSecurityContext(SafeFreeNegoCredentials credential, SafeDeleteContext& context, String targetName, ContextFlagsPal inFlags, SecurityBuffer inputBuffer, SecurityBuffer outputBuffer, ContextFlagsPal& outFlags)
at System.Net.Security.NegotiateStreamPal.InitializeSecurityContext(SafeFreeCredentials credentialsHandle, SafeDeleteContext& securityContext, String[] spns, ContextFlagsPal requestedContextFlags, SecurityBuffer[] inSecurityBufferArray, SecurityBuffer outSecurityBuffer, ContextFlagsPal& contextFlags)
at Microsoft.Data.SqlClient.SNI.SNIProxy.GenSspiClientContext(SspiClientContextStatus sspiClientContextStatus, Byte[] receivedBuff, Byte[]& sendBuff, Byte[][] serverName)
at Microsoft.Data.SqlClient.SNI.TdsParserStateObjectManaged.GenerateSspiClientContext(Byte[] receivedBuff, UInt32 receivedLength, Byte[]& sendBuff, UInt32& sendLength, Byte[][] _sniSpnBuffer)
at Microsoft.Data.SqlClient.TdsParser.SNISSPIData(Byte[] receivedBuff, UInt32 receivedLength, Byte[]& sendBuff, UInt32& sendLength)
The type initializer for 'NetSecurityNative' threw an exception.....


What could be the cause?

All Comments (12)

avatar

Hi,

Might be the PowerShell version.
7.1 was giving us problem at some point that were not present with 7.2.
It's possible the same thing is happening once again.
I've been running 7.3 for quite some time now and haven't seen this error.

I would suggest upgrading, if possible, as a first step.

Regards

Jonathan Lafontaine

avatar

Hi,

I have upgraded PS to:

<15:46:46 30.03.23> $PSVersionTable

Name Value
---- -----
PSVersion 7.3.3
PSEdition Core
GitCommitId 7.3.3


but I'm still getting the same error.

avatar

What authentication method are you using to connect to your SQL Server datasource?

Jonathan Lafontaine

avatar

Hi, its Integrated Security (active directory) and my user can access the database - test database is successfull

avatar

You are on Windows?

Jonathan Lafontaine

avatar

I can confirm the behavior on Windows with Powershell 7.3.3, RDM version 2023.1.18.0 and Devolutions.Powershell module version 2023.1.0.4.

Simply running get-rdmversion produces:

The type initializer for 'NetSecurityNative' threw an exception.
at Interop.NetSecurityNative.ImportPrincipalName(Status& minorStatus, String inputName, Int32 inputNameByteCount, SafeGssNameHandle& outputName)
at Microsoft.Win32.SafeHandles.SafeGssNameHandle.CreatePrincipal(String name)
at System.Net.Security.SafeDeleteNegoContext..ctor(SafeFreeNegoCredentials credential, String targetName)
at System.Net.Security.NegotiateStreamPal.EstablishSecurityContext(SafeFreeNegoCredentials credential, SafeDeleteContext& context, String targetName, ContextFlagsPal inFlags, SecurityBuffer inputBuffer, SecurityBuffer outputBuffer, ContextFlagsPal& outFlags)
at System.Net.Security.NegotiateStreamPal.InitializeSecurityContext(SafeFreeCredentials credentialsHandle, SafeDeleteContext& securityContext, String[] spns, ContextFlagsPal requestedContextFlags, SecurityBuffer[] inSecurityBufferArray, SecurityBuffer outSecurityBuffer, ContextFlagsPal& contextFlags)
at Microsoft.Data.SqlClient.SNI.SNIProxy.GenSspiClientContext(SspiClientContextStatus sspiClientContextStatus, Byte[] receivedBuff, Byte[]& sendBuff, Byte[][] serverName)
at Microsoft.Data.SqlClient.SNI.TdsParserStateObjectManaged.GenerateSspiClientContext(Byte[] receivedBuff, UInt32 receivedLength, Byte[]& sendBuff, UInt32& sendLength, Byte[][] _sniSpnBuffer)
at Microsoft.Data.SqlClient.TdsParser.SNISSPIData(Byte[] receivedBuff, UInt32 receivedLength, Byte[]& sendBuff, UInt32& sendLength)
The type initializer for 'NetSecurityNative' threw an exception.
at Interop.NetSecurityNative.ImportPrincipalName(Status& minorStatus, String inputName, Int32 inputNameByteCount, SafeGssNameHandle& outputName)
at Microsoft.Win32.SafeHandles.SafeGssNameHandle.CreatePrincipal(String name)
at System.Net.Security.SafeDeleteNegoContext..ctor(SafeFreeNegoCredentials credential, String targetName)
at System.Net.Security.NegotiateStreamPal.EstablishSecurityContext(SafeFreeNegoCredentials credential, SafeDeleteContext& context, String targetName, ContextFlagsPal inFlags, SecurityBuffer inputBuffer, SecurityBuffer outputBuffer, ContextFlagsPal& outFlags)
at System.Net.Security.NegotiateStreamPal.InitializeSecurityContext(SafeFreeCredentials credentialsHandle, SafeDeleteContext& securityContext, String[] spns, ContextFlagsPal requestedContextFlags, SecurityBuffer[] inSecurityBufferArray, SecurityBuffer outSecurityBuffer, ContextFlagsPal& contextFlags)
at Microsoft.Data.SqlClient.SNI.SNIProxy.GenSspiClientContext(SspiClientContextStatus sspiClientContextStatus, Byte[] receivedBuff, Byte[]& sendBuff, Byte[][] serverName)
at Microsoft.Data.SqlClient.SNI.TdsParserStateObjectManaged.GenerateSspiClientContext(Byte[] receivedBuff, UInt32 receivedLength, Byte[]& sendBuff, UInt32& sendLength, Byte[][] _sniSpnBuffer)
at Microsoft.Data.SqlClient.TdsParser.SNISSPIData(Byte[] receivedBuff, UInt32 receivedLength, Byte[]& sendBuff, UInt32& sendLength)
2023.1.18.0

avatar

Thank you angelfreire !
@Jonathan Lafontaine - yes, I'm on windows, tried both Windows 11 and Server 2019

avatar

Same issue here with Windows 11, Powershell 7.3.3, and integrated security on SQL Server.
RDM 2023.1.20.0
Jonathan Lafontaine Please help us!

avatar

I'm working on a fix for this issue.
It should land soon.

Jonathan Lafontaine

avatar

Thankyou for it

avatar

Version 2023.1.0.5 is online and will hopefully fix your issues.
Let me know if it is the case.

Regards

Jonathan Lafontaine

avatar

Just tested with our existing scripts and everything is working again. Thanks!