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

DsMakePasswordCredentialsA

関数
ユーザー名とパスワードから認証資格情報を作成する(ANSI版)。
DLLNTDSAPI.dll文字セットANSI (-A)呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// NTDSAPI.dll  (ANSI / -A)
#include <windows.h>

DWORD DsMakePasswordCredentialsA(
    LPCSTR User,   // optional
    LPCSTR Domain,   // optional
    LPCSTR Password,   // optional
    void** pAuthIdentity
);

パラメーター

名前方向
UserLPCSTRinoptional
DomainLPCSTRinoptional
PasswordLPCSTRinoptional
pAuthIdentityvoid**out

戻り値の型: DWORD

各言語での呼び出し定義

// NTDSAPI.dll  (ANSI / -A)
#include <windows.h>

DWORD DsMakePasswordCredentialsA(
    LPCSTR User,   // optional
    LPCSTR Domain,   // optional
    LPCSTR Password,   // optional
    void** pAuthIdentity
);
[DllImport("NTDSAPI.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint DsMakePasswordCredentialsA(
    [MarshalAs(UnmanagedType.LPStr)] string User,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string Domain,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string Password,   // LPCSTR optional
    IntPtr pAuthIdentity   // void** out
);
<DllImport("NTDSAPI.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function DsMakePasswordCredentialsA(
    <MarshalAs(UnmanagedType.LPStr)> User As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> Domain As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> Password As String,   ' LPCSTR optional
    pAuthIdentity As IntPtr   ' void** out
) As UInteger
End Function
' User : LPCSTR optional
' Domain : LPCSTR optional
' Password : LPCSTR optional
' pAuthIdentity : void** out
Declare PtrSafe Function DsMakePasswordCredentialsA Lib "ntdsapi" ( _
    ByVal User As String, _
    ByVal Domain As String, _
    ByVal Password As String, _
    ByVal pAuthIdentity As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DsMakePasswordCredentialsA = ctypes.windll.ntdsapi.DsMakePasswordCredentialsA
DsMakePasswordCredentialsA.restype = wintypes.DWORD
DsMakePasswordCredentialsA.argtypes = [
    wintypes.LPCSTR,  # User : LPCSTR optional
    wintypes.LPCSTR,  # Domain : LPCSTR optional
    wintypes.LPCSTR,  # Password : LPCSTR optional
    ctypes.c_void_p,  # pAuthIdentity : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('NTDSAPI.dll')
DsMakePasswordCredentialsA = Fiddle::Function.new(
  lib['DsMakePasswordCredentialsA'],
  [
    Fiddle::TYPE_VOIDP,  # User : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # Domain : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # Password : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # pAuthIdentity : void** out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "ntdsapi")]
extern "system" {
    fn DsMakePasswordCredentialsA(
        User: *const u8,  // LPCSTR optional
        Domain: *const u8,  // LPCSTR optional
        Password: *const u8,  // LPCSTR optional
        pAuthIdentity: *mut *mut ()  // void** out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("NTDSAPI.dll", CharSet = CharSet.Ansi)]
public static extern uint DsMakePasswordCredentialsA([MarshalAs(UnmanagedType.LPStr)] string User, [MarshalAs(UnmanagedType.LPStr)] string Domain, [MarshalAs(UnmanagedType.LPStr)] string Password, IntPtr pAuthIdentity);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NTDSAPI_DsMakePasswordCredentialsA' -Namespace Win32 -PassThru
# $api::DsMakePasswordCredentialsA(User, Domain, Password, pAuthIdentity)
#uselib "NTDSAPI.dll"
#func global DsMakePasswordCredentialsA "DsMakePasswordCredentialsA" sptr, sptr, sptr, sptr
; DsMakePasswordCredentialsA User, Domain, Password, pAuthIdentity   ; 戻り値は stat
; User : LPCSTR optional -> "sptr"
; Domain : LPCSTR optional -> "sptr"
; Password : LPCSTR optional -> "sptr"
; pAuthIdentity : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "NTDSAPI.dll"
#cfunc global DsMakePasswordCredentialsA "DsMakePasswordCredentialsA" str, str, str, sptr
; res = DsMakePasswordCredentialsA(User, Domain, Password, pAuthIdentity)
; User : LPCSTR optional -> "str"
; Domain : LPCSTR optional -> "str"
; Password : LPCSTR optional -> "str"
; pAuthIdentity : void** out -> "sptr"
; DWORD DsMakePasswordCredentialsA(LPCSTR User, LPCSTR Domain, LPCSTR Password, void** pAuthIdentity)
#uselib "NTDSAPI.dll"
#cfunc global DsMakePasswordCredentialsA "DsMakePasswordCredentialsA" str, str, str, intptr
; res = DsMakePasswordCredentialsA(User, Domain, Password, pAuthIdentity)
; User : LPCSTR optional -> "str"
; Domain : LPCSTR optional -> "str"
; Password : LPCSTR optional -> "str"
; pAuthIdentity : void** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ntdsapi = windows.NewLazySystemDLL("NTDSAPI.dll")
	procDsMakePasswordCredentialsA = ntdsapi.NewProc("DsMakePasswordCredentialsA")
)

// User (LPCSTR optional), Domain (LPCSTR optional), Password (LPCSTR optional), pAuthIdentity (void** out)
r1, _, err := procDsMakePasswordCredentialsA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(User))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(Domain))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(Password))),
	uintptr(pAuthIdentity),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function DsMakePasswordCredentialsA(
  User: PAnsiChar;   // LPCSTR optional
  Domain: PAnsiChar;   // LPCSTR optional
  Password: PAnsiChar;   // LPCSTR optional
  pAuthIdentity: Pointer   // void** out
): DWORD; stdcall;
  external 'NTDSAPI.dll' name 'DsMakePasswordCredentialsA';
result := DllCall("NTDSAPI\DsMakePasswordCredentialsA"
    , "AStr", User   ; LPCSTR optional
    , "AStr", Domain   ; LPCSTR optional
    , "AStr", Password   ; LPCSTR optional
    , "Ptr", pAuthIdentity   ; void** out
    , "UInt")   ; return: DWORD
●DsMakePasswordCredentialsA(User, Domain, Password, pAuthIdentity) = DLL("NTDSAPI.dll", "dword DsMakePasswordCredentialsA(char*, char*, char*, void*)")
# 呼び出し: DsMakePasswordCredentialsA(User, Domain, Password, pAuthIdentity)
# User : LPCSTR optional -> "char*"
# Domain : LPCSTR optional -> "char*"
# Password : LPCSTR optional -> "char*"
# pAuthIdentity : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。