Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) ScMinidriver - Change Smart Card PIN (or USB token PIN)See more ScMinidriver ExamplesDemonstrates how to change the PIN for a smart card or USB token.
-- 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 List Readers or 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 -- If successful, the name of the currently inserted smart card is available: EXEC sp_OAGetProperty @scmd, 'CardName', @sTmp0 OUT PRINT 'Card name: ' + @sTmp0 -- Change the "user" PIN. (Typically, you'll always be using the "user" PIN.) DECLARE @currentPin nvarchar(4000) SELECT @currentPin = '0000' DECLARE @newPin nvarchar(4000) SELECT @newPin = '1234' DECLARE @retval int EXEC sp_OAMethod @scmd, 'PinChange', @retval OUT, 'user', @currentPin, @newPin IF @retval = -1 BEGIN PRINT 'The PIN is already blocked.' EXEC @hr = sp_OADestroy @scmd RETURN END IF @retval = -2 BEGIN PRINT 'The PinChange function failed for some unanticipated reason' EXEC sp_OAGetProperty @scmd, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @scmd RETURN END IF @retval = 0 BEGIN PRINT 'PIN successfully changed.' END ELSE BEGIN PRINT 'Current PIN is incorrect.' PRINT 'Number of attempts remaining = ' + @retval END EXEC sp_OAMethod @scmd, 'DeleteContext', @success OUT EXEC @hr = sp_OADestroy @scmd END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.