SQL Server
SQL Server
Send a Wake-on-LAN Packet with a SecureOn Password
See more Socket/SSL/TLS Examples
Demonstrates Socket.SendWakeOnLan2, which sends a Wake-on-LAN magic packet that includes a SecureOn password.
Background. The password is a hexadecimal string representing four or six bytes and should come from a secure source. This is otherwise the same as SendWakeOnLan.
Chilkat SQL Server Downloads
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
DECLARE @socket int
EXEC @hr = sp_OACreate 'Chilkat.Socket', @socket OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Send a Wake-on-LAN magic packet that includes a SecureOn password. The password is a hexadecimal
-- string representing four or six bytes, and should come from a secure source rather than being
-- hard-coded.
DECLARE @secureOnPassword nvarchar(4000)
SELECT @secureOnPassword = 'AABBCCDDEEFF'
EXEC sp_OAMethod @socket, 'SendWakeOnLan2', @success OUT, '000102030405', 9, '255.255.255.255', @secureOnPassword
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @socket, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @socket
RETURN
END
PRINT 'Wake-on-LAN packet sent.'
EXEC @hr = sp_OADestroy @socket
END
GO