Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

SQL Server Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(SQL Server) ScMinidriver - Get Smartcard Properties

See more ScMinidriver Examples

Gets information about the smart card currently inserted in the reader (or USB token).

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example requires the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @scmd int
    -- Use "Chilkat_9_5_0.ScMinidriver" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.ScMinidriver', @scmd OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    -- Reader names (smart card readers or USB tokens) can be discovered
    -- via PCSC List Readers or PCSC Find Smart Cards
    DECLARE @readerName nvarchar(4000)
    SELECT @readerName = 'Alcor Micro USB Smart Card Reader 0'
    DECLARE @success int
    EXEC sp_OAMethod @scmd, 'AcquireContext', @success OUT, @readerName
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @scmd, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @scmd
        RETURN
      END

    DECLARE @json int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT

    EXEC sp_OASetProperty @json, 'EmitCompact', 0

    EXEC sp_OAMethod @scmd, 'GetCardProperties', @success OUT, @json
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @scmd, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @scmd
        EXEC @hr = sp_OADestroy @json
        RETURN
      END

    EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    -- Here is sample output:
    -- See below for sample code to parse the JSON.
    -- 
    -- NOTE: Not all smart cards support all properties.
    -- The GetCardProperties method will return information for all properties supported by the card.

    -- {
    --   "bytesAvailable": 74752,
    --   "containersAvailable": 18,
    --   "maxKeyContainers": 20,
    --   "capabilities": {
    --     "fCertificateCompression": false,
    --     "fKeyGen": true
    --   },
    --   "keySizes": {
    --     "minimumBitlen": 2048,
    --     "defaultBitlen": 2048,
    --     "maximumBitlen": 4096,
    --     "incrementalBitlen": 1024
    --   },
    --   "readOnly": false,
    --   "cacheMode": "global",
    --   "supportsWinX509Enrollment": true,
    --   "guid": "1201803d-03e6-772a-3d80-0112e6032a77",
    --   "serial": "e6032a773d800112e6032a77",
    --   "pins": [
    --     "user",
    --     "admin",
    --     "role3",
    --     "role4"
    --   ],
    --   "pin": {
    --     "user": {
    --       "type": "regular",
    --       "purpose": "primaryCard",
    --       "changePermission": [
    --         "user"
    --       ],
    --       "unblockPermission": [
    --         "admin"
    --       ],
    --       "cachePolicy": "normal",
    --       "policyInfo": "00000000",
    --       "flags": "00000000",
    --       "acceptPlainTextPin": true,
    --       "generateSessionPin": false
    --     },
    --     "admin": {
    --       "type": "challenge/response",
    --       "purpose": "administrator",
    --       "changePermission": [
    --         "admin"
    --       ],
    --       "cachePolicy": "normal",
    --       "policyInfo": "00000000",
    --       "flags": "00000000"
    --     },
    --     "role3": {
    --       "type": "regular",
    --       "purpose": "digitalSignature",
    --       "changePermission": [
    --         "role3"
    --       ],
    --       "unblockPermission": [
    --         "role4"
    --       ],
    --       "cachePolicy": "alwaysPrompt",
    --       "policyInfo": "00000000",
    --       "flags": "00000000",
    --       "acceptPlainTextPin": true,
    --       "generateSessionPin": false
    --     },
    --     "role4": {
    --       "type": "regular",
    --       "purpose": "unblockOnly",
    --       "changePermission": [
    --         "role4"
    --       ],
    --       "cachePolicy": "normal",
    --       "policyInfo": "00000000",
    --       "flags": "00000000",
    --       "acceptPlainTextPin": true,
    --       "generateSessionPin": false
    --     }
    --   },
    --   "importSupport": [
    --     "plainText",
    --     "rsaKeyest",
    --     "eccKeyest",
    --     "symmetric"
    --   ],
    --   "algorithms": [
    --     "AES"
    --   ],
    --   "paddingSchemes": [
    --     "block",
    --     "pkcs1",
    --     "pss",
    --     "oaep"
    --   ],
    --   "chainingModes": [
    --     "ChainingModeCBC"
    --   ]
    -- }

    -- Use this online tool to generate parsing code from sample JSON: 
    -- Generate Parsing Code from JSON

    DECLARE @strVal nvarchar(4000)

    DECLARE @bytesAvailable int
    EXEC sp_OAMethod @json, 'IntOf', @bytesAvailable OUT, 'bytesAvailable'
    DECLARE @containersAvailable int
    EXEC sp_OAMethod @json, 'IntOf', @containersAvailable OUT, 'containersAvailable'
    DECLARE @maxKeyContainers int
    EXEC sp_OAMethod @json, 'IntOf', @maxKeyContainers OUT, 'maxKeyContainers'
    DECLARE @capabilitiesFCertificateCompression int
    EXEC sp_OAMethod @json, 'BoolOf', @capabilitiesFCertificateCompression OUT, 'capabilities.fCertificateCompression'
    DECLARE @capabilitiesFKeyGen int
    EXEC sp_OAMethod @json, 'BoolOf', @capabilitiesFKeyGen OUT, 'capabilities.fKeyGen'
    DECLARE @keySizesMinimumBitlen int
    EXEC sp_OAMethod @json, 'IntOf', @keySizesMinimumBitlen OUT, 'keySizes.minimumBitlen'
    DECLARE @keySizesDefaultBitlen int
    EXEC sp_OAMethod @json, 'IntOf', @keySizesDefaultBitlen OUT, 'keySizes.defaultBitlen'
    DECLARE @keySizesMaximumBitlen int
    EXEC sp_OAMethod @json, 'IntOf', @keySizesMaximumBitlen OUT, 'keySizes.maximumBitlen'
    DECLARE @keySizesIncrementalBitlen int
    EXEC sp_OAMethod @json, 'IntOf', @keySizesIncrementalBitlen OUT, 'keySizes.incrementalBitlen'
    DECLARE @readOnly int
    EXEC sp_OAMethod @json, 'BoolOf', @readOnly OUT, 'readOnly'
    DECLARE @cacheMode nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @cacheMode OUT, 'cacheMode'
    DECLARE @supportsWinX509Enrollment int
    EXEC sp_OAMethod @json, 'BoolOf', @supportsWinX509Enrollment OUT, 'supportsWinX509Enrollment'
    DECLARE @guid nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @guid OUT, 'guid'
    DECLARE @serial nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @serial OUT, 'serial'
    DECLARE @pinUserType nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinUserType OUT, 'pin.user.type'
    DECLARE @pinUserPurpose nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinUserPurpose OUT, 'pin.user.purpose'
    DECLARE @pinUserCachePolicy nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinUserCachePolicy OUT, 'pin.user.cachePolicy'
    DECLARE @pinUserPolicyInfo nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinUserPolicyInfo OUT, 'pin.user.policyInfo'
    DECLARE @pinUserFlags nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinUserFlags OUT, 'pin.user.flags'
    DECLARE @pinUserAcceptPlainTextPin int
    EXEC sp_OAMethod @json, 'BoolOf', @pinUserAcceptPlainTextPin OUT, 'pin.user.acceptPlainTextPin'
    DECLARE @pinUserGenerateSessionPin int
    EXEC sp_OAMethod @json, 'BoolOf', @pinUserGenerateSessionPin OUT, 'pin.user.generateSessionPin'
    DECLARE @pinAdminType nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinAdminType OUT, 'pin.admin.type'
    DECLARE @pinAdminPurpose nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinAdminPurpose OUT, 'pin.admin.purpose'
    DECLARE @pinAdminCachePolicy nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinAdminCachePolicy OUT, 'pin.admin.cachePolicy'
    DECLARE @pinAdminPolicyInfo nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinAdminPolicyInfo OUT, 'pin.admin.policyInfo'
    DECLARE @pinAdminFlags nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinAdminFlags OUT, 'pin.admin.flags'
    DECLARE @pinRole3Type nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinRole3Type OUT, 'pin.role3.type'
    DECLARE @pinRole3Purpose nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinRole3Purpose OUT, 'pin.role3.purpose'
    DECLARE @pinRole3CachePolicy nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinRole3CachePolicy OUT, 'pin.role3.cachePolicy'
    DECLARE @pinRole3PolicyInfo nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinRole3PolicyInfo OUT, 'pin.role3.policyInfo'
    DECLARE @pinRole3Flags nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinRole3Flags OUT, 'pin.role3.flags'
    DECLARE @pinRole3AcceptPlainTextPin int
    EXEC sp_OAMethod @json, 'BoolOf', @pinRole3AcceptPlainTextPin OUT, 'pin.role3.acceptPlainTextPin'
    DECLARE @pinRole3GenerateSessionPin int
    EXEC sp_OAMethod @json, 'BoolOf', @pinRole3GenerateSessionPin OUT, 'pin.role3.generateSessionPin'
    DECLARE @pinRole4Type nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinRole4Type OUT, 'pin.role4.type'
    DECLARE @pinRole4Purpose nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinRole4Purpose OUT, 'pin.role4.purpose'
    DECLARE @pinRole4CachePolicy nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinRole4CachePolicy OUT, 'pin.role4.cachePolicy'
    DECLARE @pinRole4PolicyInfo nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinRole4PolicyInfo OUT, 'pin.role4.policyInfo'
    DECLARE @pinRole4Flags nvarchar(4000)
    EXEC sp_OAMethod @json, 'StringOf', @pinRole4Flags OUT, 'pin.role4.flags'
    DECLARE @pinRole4AcceptPlainTextPin int
    EXEC sp_OAMethod @json, 'BoolOf', @pinRole4AcceptPlainTextPin OUT, 'pin.role4.acceptPlainTextPin'
    DECLARE @pinRole4GenerateSessionPin int
    EXEC sp_OAMethod @json, 'BoolOf', @pinRole4GenerateSessionPin OUT, 'pin.role4.generateSessionPin'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'pins'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @json, 'I', @i
        EXEC sp_OAMethod @json, 'StringOf', @strVal OUT, 'pins[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'pin.user.changePermission'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @json, 'I', @i
        EXEC sp_OAMethod @json, 'StringOf', @strVal OUT, 'pin.user.changePermission[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'pin.user.unblockPermission'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @json, 'I', @i
        EXEC sp_OAMethod @json, 'StringOf', @strVal OUT, 'pin.user.unblockPermission[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'pin.admin.changePermission'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @json, 'I', @i
        EXEC sp_OAMethod @json, 'StringOf', @strVal OUT, 'pin.admin.changePermission[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'pin.role3.changePermission'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @json, 'I', @i
        EXEC sp_OAMethod @json, 'StringOf', @strVal OUT, 'pin.role3.changePermission[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'pin.role3.unblockPermission'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @json, 'I', @i
        EXEC sp_OAMethod @json, 'StringOf', @strVal OUT, 'pin.role3.unblockPermission[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'pin.role4.changePermission'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @json, 'I', @i
        EXEC sp_OAMethod @json, 'StringOf', @strVal OUT, 'pin.role4.changePermission[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'importSupport'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @json, 'I', @i
        EXEC sp_OAMethod @json, 'StringOf', @strVal OUT, 'importSupport[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'algorithms'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @json, 'I', @i
        EXEC sp_OAMethod @json, 'StringOf', @strVal OUT, 'algorithms[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'paddingSchemes'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @json, 'I', @i
        EXEC sp_OAMethod @json, 'StringOf', @strVal OUT, 'paddingSchemes[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'chainingModes'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @json, 'I', @i
        EXEC sp_OAMethod @json, 'StringOf', @strVal OUT, 'chainingModes[i]'
        SELECT @i = @i + 1
      END

    -- Delete the context when finished with the card.
    EXEC sp_OAMethod @scmd, 'DeleteContext', @success OUT
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @scmd, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
      END

    EXEC @hr = sp_OADestroy @scmd
    EXEC @hr = sp_OADestroy @json


END
GO

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.