📄 jwasspi.pas
字号:
{******************************************************************************}
{ }
{ Security Service Provider API interface Unit for Object Pascal }
{ }
{ Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
{ Corporation. All Rights Reserved. }
{ }
{ The original file is: sspi.h, released June 2000. The original Pascal }
{ code is: Sspi.pas, released December 2000. The initial developer of the }
{ Pascal code is Marcel van Brakel (brakelm@chello.nl). }
{ }
{ Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
{ Marcel van Brakel. All Rights Reserved. }
{ }
{ Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
{ }
{ You may retrieve the latest version of this file at the Project JEDI home }
{ page, located at http://delphi-jedi.org or my personal homepage located at }
{ http://members.chello.nl/m.vanbrakel2 }
{ }
{ The contents of this file are used with permission, subject to the Mozilla }
{ Public License Version 1.1 (the "License"); you may not use this file except }
{ in compliance with the License. You may obtain a copy of the License at }
{ http://www.mozilla.org/MPL/MPL-1.1.html }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, }
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
{ the specific language governing rights and limitations under the License. }
{ }
{ Alternatively, the contents of this file may be used under the terms of the }
{ GNU Lesser General Public License (the "LGPL License"), in which case the }
{ provisions of the LGPL License are applicable instead of those above. }
{ If you wish to allow use of your version of this file only under the terms }
{ of the LGPL License and not to allow others to use your version of this file }
{ under the MPL, indicate your decision by deleting the provisions above and }
{ replace them with the notice and other provisions required by the LGPL }
{ License. If you do not delete the provisions above, a recipient may use }
{ your version of this file under either the MPL or the LGPL License. }
{ }
{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
{ }
{******************************************************************************}
unit JwaSspi;
{$WEAKPACKAGEUNIT}
{$HPPEMIT ''}
{$HPPEMIT '#include "sspi.h"'}
{$HPPEMIT ''}
{$HPPEMIT '#typedef SEC_CHAR *PSEC_CHAR'}
{$HPPEMIT '#typedef SEC_WCHAR *PSEC_WCHAR'}
{$HPPEMIT ''}
{$I WINDEFINES.INC}
interface
uses
JwaWinType;
//
// Determine environment:
//
const
ISSP_LEVEL = 32;
{$EXTERNALSYM ISSP_LEVEL}
ISSP_MODE = 1;
{$EXTERNALSYM ISSP_MODE}
//
// Now, define platform specific mappings:
//
//
// For NT-2 and up, wtypes will define HRESULT to be long.
//
type
SEC_WCHAR = WCHAR;
{$EXTERNALSYM SEC_WCHAR}
PSEC_WCHAR = ^SEC_CHAR;
{$NODEFINE PSEC_WCHAR}
PSecWChar = ^TSecWChar;
TSecWChar = SEC_WCHAR;
SEC_CHAR = CHAR;
{$EXTERNALSYM SEC_CHAR}
PSEC_CHAR = ^SEC_CHAR;
{$NODEFINE PSEC_CHAR}
PSecChar = ^TSecChar;
TSecChar = SEC_CHAR;
SECURITY_STATUS = LONG;
{$EXTERNALSYM SECURITY_STATUS}
PSecurityStatus = ^TSecurityStatus;
TSecurityStatus = SECURITY_STATUS;
//
// Decide what a string - 32 bits only since for 16 bits it is clear.
//
{$IFDEF UNICODE}
SECURITY_PSTR = ^SEC_WCHAR;
{$EXTERNALSYM SECURITY_PSTR}
SECURITY_PCSTR = ^SEC_WCHAR;
{$EXTERNALSYM SECURITY_PCSTR}
{$ELSE}
SECURITY_PSTR = ^SEC_CHAR;
{$EXTERNALSYM SECURITY_PSTR}
SECURITY_PCSTR = ^SEC_CHAR;
{$EXTERNALSYM SECURITY_PCSTR}
{$ENDIF}
//
// Okay, security specific types:
//
PSecHandle = ^SecHandle;
{$EXTERNALSYM PSecHandle}
_SecHandle = record
dwLower: ULONG_PTR;
dwUpper: ULONG_PTR;
end;
{$EXTERNALSYM _SecHandle}
SecHandle = _SecHandle;
{$EXTERNALSYM SecHandle}
TSecHandle = SecHandle;
procedure SecInvalidateHandle(var x: SecHandle);
{$EXTERNALSYM SecInvalidateHandle}
function SecIsValidHandle(x: SecHandle): Boolean;
{$EXTERNALSYM SecIsValidHandle}
type
CredHandle = SecHandle;
{$EXTERNALSYM CredHandle}
PCredHandle = ^CredHandle;
{$EXTERNALSYM PCredHandle}
TCredHandle = CredHandle;
CtxtHandle = SecHandle;
{$EXTERNALSYM CtxtHandle}
PCtxtHandle = ^CtxtHandle;
{$EXTERNALSYM PCtxthandle}
TCtxthandle = CtxtHandle;
_SECURITY_INTEGER = LARGE_INTEGER;
{$EXTERNALSYM _SECURITY_INTEGER}
SECURITY_INTEGER = _SECURITY_INTEGER;
{$EXTERNALSYM SECURITY_INTEGER}
PSECURITY_INTEGER = ^SECURITY_INTEGER;
{$EXTERNALSYM PSECURITY_INTEGER}
// todo Timestamp was removed from SSPI in August 2001 PSDK, where is it now?!
TimeStamp = SECURITY_INTEGER;
{$EXTERNALSYM TimeStamp}
PTimeStamp = ^SECURITY_INTEGER;
{$EXTERNALSYM PTimeStamp}
TTimeStamp = TimeStamp;
//
// If we are in 32 bit mode, define the SECURITY_STRING structure,
// as a clone of the base UNICODE_STRING structure. This is used
// internally in security components, an as the string interface
// for kernel components (e.g. FSPs)
//
SECURITY_STRING = UNICODE_STRING;
{$EXTERNALSYM SECURITY_STRING}
PSECURITY_STRING = ^SECURITY_STRING;
{$EXTERNALSYM PSECURITY_STRING}
TSecurityString = SECURITY_STRING;
PSecurityString = PSECURITY_STRING;
//
// SecPkgInfo structure
//
// Provides general information about a security provider
//
PSecPkgInfoW = ^SecPkgInfoW;
{$EXTERNALSYM PSecPkgInfoW}
_SecPkgInfoW = record
fCapabilities: Cardinal; // Capability bitmask
wVersion: Word; // Version of driver
wRPCID: Word; // ID for RPC Runtime
cbMaxToken: Cardinal; // Size of authentication token (max)
Name: PSecWChar; // Text name
Comment: PSecWChar; // Comment
end;
{$EXTERNALSYM _SecPkgInfoW}
SecPkgInfoW = _SecPkgInfoW;
{$EXTERNALSYM SecPkgInfoW}
TSecPkgInfoW = SecPkgInfoW;
PSecPkgInfoA = ^SecPkgInfoA;
{$EXTERNALSYM PSecPkgInfoA}
_SecPkgInfoA = record
fCapabilities: Cardinal; // Capability bitmask
wVersion: Word; // Version of driver
wRPCID: Word; // ID for RPC Runtime
cbMaxToken: Cardinal; // Size of authentication token (max)
Name: PSecChar; // Text name
Comment: PSecChar; // Comment
end;
{$EXTERNALSYM _SecPkgInfoA}
SecPkgInfoA = _SecPkgInfoA;
{$EXTERNALSYM SecPkgInfoA}
TSecPkgInfoA = SecPkgInfoA;
{$IFDEF UNICODE}
SecPkgInfo = SecPkgInfoW;
{$EXTERNALSYM SecPkgInfo}
PSecPkgInfo = PSecPkgInfoW;
{$EXTERNALSYM PSecPkgInfo}
TSecPkgInfo = TSecPkgInfoW;
{$ELSE}
SecPkgInfo = SecPkgInfoA;
{$EXTERNALSYM SecPkgInfo}
PSecPkgInfo = PSecPkgInfoA;
{$EXTERNALSYM PSecPkgInfo}
TSecPkgInfo = TSecPkgInfoA;
{$ENDIF}
//
// Security Package Capabilities
//
const
SECPKG_FLAG_INTEGRITY = $00000001; // Supports integrity on messages
{$EXTERNALSYM SECPKG_FLAG_INTEGRITY}
SECPKG_FLAG_PRIVACY = $00000002; // Supports privacy (confidentiality)
{$EXTERNALSYM SECPKG_FLAG_PRIVACY}
SECPKG_FLAG_TOKEN_ONLY = $00000004; // Only security token needed
{$EXTERNALSYM SECPKG_FLAG_TOKEN_ONLY}
SECPKG_FLAG_DATAGRAM = $00000008; // Datagram RPC support
{$EXTERNALSYM SECPKG_FLAG_DATAGRAM}
SECPKG_FLAG_CONNECTION = $00000010; // Connection oriented RPC support
{$EXTERNALSYM SECPKG_FLAG_CONNECTION}
SECPKG_FLAG_MULTI_REQUIRED = $00000020; // Full 3-leg required for re-auth.
{$EXTERNALSYM SECPKG_FLAG_MULTI_REQUIRED}
SECPKG_FLAG_CLIENT_ONLY = $00000040; // Server side functionality not available
{$EXTERNALSYM SECPKG_FLAG_CLIENT_ONLY}
SECPKG_FLAG_EXTENDED_ERROR = $00000080; // Supports extended error msgs
{$EXTERNALSYM SECPKG_FLAG_EXTENDED_ERROR}
SECPKG_FLAG_IMPERSONATION = $00000100; // Supports impersonation
{$EXTERNALSYM SECPKG_FLAG_IMPERSONATION}
SECPKG_FLAG_ACCEPT_WIN32_NAME = $00000200; // Accepts Win32 names
{$EXTERNALSYM SECPKG_FLAG_ACCEPT_WIN32_NAME}
SECPKG_FLAG_STREAM = $00000400; // Supports stream semantics
{$EXTERNALSYM SECPKG_FLAG_STREAM}
SECPKG_FLAG_NEGOTIABLE = $00000800; // Can be used by the negotiate package
{$EXTERNALSYM SECPKG_FLAG_NEGOTIABLE}
SECPKG_FLAG_GSS_COMPATIBLE = $00001000; // GSS Compatibility Available
{$EXTERNALSYM SECPKG_FLAG_GSS_COMPATIBLE}
SECPKG_FLAG_LOGON = $00002000; // Supports common LsaLogonUser
{$EXTERNALSYM SECPKG_FLAG_LOGON}
SECPKG_FLAG_ASCII_BUFFERS = $00004000; // Token Buffers are in ASCII
{$EXTERNALSYM SECPKG_FLAG_ASCII_BUFFERS}
SECPKG_FLAG_FRAGMENT = $00008000; // Package can fragment to fit
{$EXTERNALSYM SECPKG_FLAG_FRAGMENT}
SECPKG_FLAG_MUTUAL_AUTH = $00010000; // Package can perform mutual authentication
{$EXTERNALSYM SECPKG_FLAG_MUTUAL_AUTH}
SECPKG_FLAG_DELEGATION = $00020000; // Package can delegate
{$EXTERNALSYM SECPKG_FLAG_DELEGATION}
SECPKG_ID_NONE = $FFFF;
{$EXTERNALSYM SECPKG_ID_NONE}
//
// SecBuffer
//
// Generic memory descriptors for buffers passed in to the security
// API
//
type
PSecBuffer = ^SecBuffer;
{$EXTERNALSYM PSecBuffer}
_SecBuffer = record
cbBuffer: Cardinal; // Size of the buffer, in bytes
BufferType: Cardinal; // Type of the buffer (below)
pvBuffer: Pointer; // Pointer to the buffer
end;
{$EXTERNALSYM _SecBuffer}
SecBuffer = _SecBuffer;
{$EXTERNALSYM SecBuffer}
TSecBuffer = SecBuffer;
PSecBufferDesc = ^SecBufferDesc;
{$EXTERNALSYM PSecBufferDesc}
_SecBufferDesc = record
ulVersion: Cardinal; // Version number
cBuffers: Cardinal; // Number of buffers
pBuffers: PSecBuffer; // Pointer to array of buffers
end;
{$EXTERNALSYM _SecBufferDesc}
SecBufferDesc = _SecBufferDesc;
{$EXTERNALSYM SecBufferDesc}
TSecBufferDesc = SecBufferDesc;
const
SECBUFFER_VERSION = 0;
{$EXTERNALSYM SECBUFFER_VERSION}
SECBUFFER_EMPTY = 0; // Undefined, replaced by provider
{$EXTERNALSYM SECBUFFER_EMPTY}
SECBUFFER_DATA = 1; // Packet data
{$EXTERNALSYM SECBUFFER_DATA}
SECBUFFER_TOKEN = 2; // Security token
{$EXTERNALSYM SECBUFFER_TOKEN}
SECBUFFER_PKG_PARAMS = 3; // Package specific parameters
{$EXTERNALSYM SECBUFFER_PKG_PARAMS}
SECBUFFER_MISSING = 4; // Missing Data indicator
{$EXTERNALSYM SECBUFFER_MISSING}
SECBUFFER_EXTRA = 5; // Extra data
{$EXTERNALSYM SECBUFFER_EXTRA}
SECBUFFER_STREAM_TRAILER = 6; // Security Trailer
{$EXTERNALSYM SECBUFFER_STREAM_TRAILER}
SECBUFFER_STREAM_HEADER = 7; // Security Header
{$EXTERNALSYM SECBUFFER_STREAM_HEADER}
SECBUFFER_NEGOTIATION_INFO = 8; // Hints from the negotiation pkg
{$EXTERNALSYM SECBUFFER_NEGOTIATION_INFO}
SECBUFFER_PADDING = 9; // non-data padding
{$EXTERNALSYM SECBUFFER_PADDING}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -