Win32 API 日本語リファレンス
ホームNetworking.Clustering › ClusterSetAccountAccess

ClusterSetAccountAccess

関数
クラスタに対するアカウントのアクセス権を設定する。
DLLCLUSAPI.dll呼出規約winapi対応OSwindowsserver2016

シグネチャ

// CLUSAPI.dll
#include <windows.h>

DWORD ClusterSetAccountAccess(
    HCLUSTER hCluster,
    LPCWSTR szAccountSID,
    DWORD dwAccess,
    DWORD dwControlType
);

パラメーター

名前方向説明
hClusterHCLUSTERinアクセス権を設定する対象クラスターのハンドル。
szAccountSIDLPCWSTRin対象アカウントのSIDを表すワイド文字列。
dwAccessDWORDin付与または拒否するアクセス権のマスク。
dwControlTypeDWORDinアクセス制御の種別(許可ACEか拒否ACEか)を示す値。

戻り値の型: DWORD

各言語での呼び出し定義

// CLUSAPI.dll
#include <windows.h>

DWORD ClusterSetAccountAccess(
    HCLUSTER hCluster,
    LPCWSTR szAccountSID,
    DWORD dwAccess,
    DWORD dwControlType
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern uint ClusterSetAccountAccess(
    IntPtr hCluster,   // HCLUSTER
    [MarshalAs(UnmanagedType.LPWStr)] string szAccountSID,   // LPCWSTR
    uint dwAccess,   // DWORD
    uint dwControlType   // DWORD
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterSetAccountAccess(
    hCluster As IntPtr,   ' HCLUSTER
    <MarshalAs(UnmanagedType.LPWStr)> szAccountSID As String,   ' LPCWSTR
    dwAccess As UInteger,   ' DWORD
    dwControlType As UInteger   ' DWORD
) As UInteger
End Function
' hCluster : HCLUSTER
' szAccountSID : LPCWSTR
' dwAccess : DWORD
' dwControlType : DWORD
Declare PtrSafe Function ClusterSetAccountAccess Lib "clusapi" ( _
    ByVal hCluster As LongPtr, _
    ByVal szAccountSID As LongPtr, _
    ByVal dwAccess As Long, _
    ByVal dwControlType As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ClusterSetAccountAccess = ctypes.windll.clusapi.ClusterSetAccountAccess
ClusterSetAccountAccess.restype = wintypes.DWORD
ClusterSetAccountAccess.argtypes = [
    ctypes.c_ssize_t,  # hCluster : HCLUSTER
    wintypes.LPCWSTR,  # szAccountSID : LPCWSTR
    wintypes.DWORD,  # dwAccess : DWORD
    wintypes.DWORD,  # dwControlType : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CLUSAPI.dll')
ClusterSetAccountAccess = Fiddle::Function.new(
  lib['ClusterSetAccountAccess'],
  [
    Fiddle::TYPE_INTPTR_T,  # hCluster : HCLUSTER
    Fiddle::TYPE_VOIDP,  # szAccountSID : LPCWSTR
    -Fiddle::TYPE_INT,  # dwAccess : DWORD
    -Fiddle::TYPE_INT,  # dwControlType : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "clusapi")]
extern "system" {
    fn ClusterSetAccountAccess(
        hCluster: isize,  // HCLUSTER
        szAccountSID: *const u16,  // LPCWSTR
        dwAccess: u32,  // DWORD
        dwControlType: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern uint ClusterSetAccountAccess(IntPtr hCluster, [MarshalAs(UnmanagedType.LPWStr)] string szAccountSID, uint dwAccess, uint dwControlType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_ClusterSetAccountAccess' -Namespace Win32 -PassThru
# $api::ClusterSetAccountAccess(hCluster, szAccountSID, dwAccess, dwControlType)
#uselib "CLUSAPI.dll"
#func global ClusterSetAccountAccess "ClusterSetAccountAccess" sptr, sptr, sptr, sptr
; ClusterSetAccountAccess hCluster, szAccountSID, dwAccess, dwControlType   ; 戻り値は stat
; hCluster : HCLUSTER -> "sptr"
; szAccountSID : LPCWSTR -> "sptr"
; dwAccess : DWORD -> "sptr"
; dwControlType : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "CLUSAPI.dll"
#cfunc global ClusterSetAccountAccess "ClusterSetAccountAccess" sptr, wstr, int, int
; res = ClusterSetAccountAccess(hCluster, szAccountSID, dwAccess, dwControlType)
; hCluster : HCLUSTER -> "sptr"
; szAccountSID : LPCWSTR -> "wstr"
; dwAccess : DWORD -> "int"
; dwControlType : DWORD -> "int"
; DWORD ClusterSetAccountAccess(HCLUSTER hCluster, LPCWSTR szAccountSID, DWORD dwAccess, DWORD dwControlType)
#uselib "CLUSAPI.dll"
#cfunc global ClusterSetAccountAccess "ClusterSetAccountAccess" intptr, wstr, int, int
; res = ClusterSetAccountAccess(hCluster, szAccountSID, dwAccess, dwControlType)
; hCluster : HCLUSTER -> "intptr"
; szAccountSID : LPCWSTR -> "wstr"
; dwAccess : DWORD -> "int"
; dwControlType : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procClusterSetAccountAccess = clusapi.NewProc("ClusterSetAccountAccess")
)

// hCluster (HCLUSTER), szAccountSID (LPCWSTR), dwAccess (DWORD), dwControlType (DWORD)
r1, _, err := procClusterSetAccountAccess.Call(
	uintptr(hCluster),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szAccountSID))),
	uintptr(dwAccess),
	uintptr(dwControlType),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function ClusterSetAccountAccess(
  hCluster: NativeInt;   // HCLUSTER
  szAccountSID: PWideChar;   // LPCWSTR
  dwAccess: DWORD;   // DWORD
  dwControlType: DWORD   // DWORD
): DWORD; stdcall;
  external 'CLUSAPI.dll' name 'ClusterSetAccountAccess';
result := DllCall("CLUSAPI\ClusterSetAccountAccess"
    , "Ptr", hCluster   ; HCLUSTER
    , "WStr", szAccountSID   ; LPCWSTR
    , "UInt", dwAccess   ; DWORD
    , "UInt", dwControlType   ; DWORD
    , "UInt")   ; return: DWORD
●ClusterSetAccountAccess(hCluster, szAccountSID, dwAccess, dwControlType) = DLL("CLUSAPI.dll", "dword ClusterSetAccountAccess(int, char*, dword, dword)")
# 呼び出し: ClusterSetAccountAccess(hCluster, szAccountSID, dwAccess, dwControlType)
# hCluster : HCLUSTER -> "int"
# szAccountSID : LPCWSTR -> "char*"
# dwAccess : DWORD -> "dword"
# dwControlType : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "clusapi" fn ClusterSetAccountAccess(
    hCluster: isize, // HCLUSTER
    szAccountSID: [*c]const u16, // LPCWSTR
    dwAccess: u32, // DWORD
    dwControlType: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
proc ClusterSetAccountAccess(
    hCluster: int,  # HCLUSTER
    szAccountSID: WideCString,  # LPCWSTR
    dwAccess: uint32,  # DWORD
    dwControlType: uint32  # DWORD
): uint32 {.importc: "ClusterSetAccountAccess", stdcall, dynlib: "CLUSAPI.dll".}
pragma(lib, "clusapi");
extern(Windows)
uint ClusterSetAccountAccess(
    ptrdiff_t hCluster,   // HCLUSTER
    const(wchar)* szAccountSID,   // LPCWSTR
    uint dwAccess,   // DWORD
    uint dwControlType   // DWORD
);
ccall((:ClusterSetAccountAccess, "CLUSAPI.dll"), stdcall, UInt32,
      (Int, Cwstring, UInt32, UInt32),
      hCluster, szAccountSID, dwAccess, dwControlType)
# hCluster : HCLUSTER -> Int
# szAccountSID : LPCWSTR -> Cwstring
# dwAccess : DWORD -> UInt32
# dwControlType : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t ClusterSetAccountAccess(
    intptr_t hCluster,
    const uint16_t* szAccountSID,
    uint32_t dwAccess,
    uint32_t dwControlType);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.ClusterSetAccountAccess(hCluster, szAccountSID, dwAccess, dwControlType)
-- hCluster : HCLUSTER
-- szAccountSID : LPCWSTR
-- dwAccess : DWORD
-- dwControlType : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const ClusterSetAccountAccess = lib.func('__stdcall', 'ClusterSetAccountAccess', 'uint32_t', ['intptr_t', 'str16', 'uint32_t', 'uint32_t']);
// ClusterSetAccountAccess(hCluster, szAccountSID, dwAccess, dwControlType)
// hCluster : HCLUSTER -> 'intptr_t'
// szAccountSID : LPCWSTR -> 'str16'
// dwAccess : DWORD -> 'uint32_t'
// dwControlType : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("CLUSAPI.dll", {
  ClusterSetAccountAccess: { parameters: ["isize", "buffer", "u32", "u32"], result: "u32" },
});
// lib.symbols.ClusterSetAccountAccess(hCluster, szAccountSID, dwAccess, dwControlType)
// hCluster : HCLUSTER -> "isize"
// szAccountSID : LPCWSTR -> "buffer"
// dwAccess : DWORD -> "u32"
// dwControlType : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t ClusterSetAccountAccess(
    intptr_t hCluster,
    const uint16_t* szAccountSID,
    uint32_t dwAccess,
    uint32_t dwControlType);
C, "CLUSAPI.dll");
// $ffi->ClusterSetAccountAccess(hCluster, szAccountSID, dwAccess, dwControlType);
// hCluster : HCLUSTER
// szAccountSID : LPCWSTR
// dwAccess : DWORD
// dwControlType : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Clusapi extends StdCallLibrary {
    Clusapi INSTANCE = Native.load("clusapi", Clusapi.class);
    int ClusterSetAccountAccess(
        long hCluster,   // HCLUSTER
        WString szAccountSID,   // LPCWSTR
        int dwAccess,   // DWORD
        int dwControlType   // DWORD
    );
}
@[Link("clusapi")]
lib LibCLUSAPI
  fun ClusterSetAccountAccess = ClusterSetAccountAccess(
    hCluster : LibC::SSizeT,   # HCLUSTER
    szAccountSID : UInt16*,   # LPCWSTR
    dwAccess : UInt32,   # DWORD
    dwControlType : UInt32   # DWORD
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ClusterSetAccountAccessNative = Uint32 Function(IntPtr, Pointer<Utf16>, Uint32, Uint32);
typedef ClusterSetAccountAccessDart = int Function(int, Pointer<Utf16>, int, int);
final ClusterSetAccountAccess = DynamicLibrary.open('CLUSAPI.dll')
    .lookupFunction<ClusterSetAccountAccessNative, ClusterSetAccountAccessDart>('ClusterSetAccountAccess');
// hCluster : HCLUSTER -> IntPtr
// szAccountSID : LPCWSTR -> Pointer<Utf16>
// dwAccess : DWORD -> Uint32
// dwControlType : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ClusterSetAccountAccess(
  hCluster: NativeInt;   // HCLUSTER
  szAccountSID: PWideChar;   // LPCWSTR
  dwAccess: DWORD;   // DWORD
  dwControlType: DWORD   // DWORD
): DWORD; stdcall;
  external 'CLUSAPI.dll' name 'ClusterSetAccountAccess';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ClusterSetAccountAccess"
  c_ClusterSetAccountAccess :: CIntPtr -> CWString -> Word32 -> Word32 -> IO Word32
-- hCluster : HCLUSTER -> CIntPtr
-- szAccountSID : LPCWSTR -> CWString
-- dwAccess : DWORD -> Word32
-- dwControlType : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let clustersetaccountaccess =
  foreign "ClusterSetAccountAccess"
    (intptr_t @-> (ptr uint16_t) @-> uint32_t @-> uint32_t @-> returning uint32_t)
(* hCluster : HCLUSTER -> intptr_t *)
(* szAccountSID : LPCWSTR -> (ptr uint16_t) *)
(* dwAccess : DWORD -> uint32_t *)
(* dwControlType : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)

(cffi:defcfun ("ClusterSetAccountAccess" cluster-set-account-access :convention :stdcall) :uint32
  (h-cluster :int64)   ; HCLUSTER
  (sz-account-sid (:string :encoding :utf-16le))   ; LPCWSTR
  (dw-access :uint32)   ; DWORD
  (dw-control-type :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ClusterSetAccountAccess = Win32::API::More->new('CLUSAPI',
    'DWORD ClusterSetAccountAccess(LPARAM hCluster, LPCWSTR szAccountSID, DWORD dwAccess, DWORD dwControlType)');
# my $ret = $ClusterSetAccountAccess->Call($hCluster, $szAccountSID, $dwAccess, $dwControlType);
# hCluster : HCLUSTER -> LPARAM
# szAccountSID : LPCWSTR -> LPCWSTR
# dwAccess : DWORD -> DWORD
# dwControlType : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。