L
looyo
Unregistered / Unconfirmed
GUEST, unregistred user!
record类型定义
type
//////////////add by wanghui begin
pUnShort=^Word;
pCoAuthIdentity=^_CoAuthIdentity;
_CoAuthIdentity=record
userUnShort;
UserLength:ULONG;
DomainUnShort;
DomainLength:Ulong;
passwordUnShort;
PasswordLength:ulong;
Flags:ulong;
end;
_CoAuthInfo=record
dwAuthnSvcWORD;
dwAuthzSvcWORD;
pwszServerPrincName:WideString;
dwAuthnLevelword;
dwImpersonationLevel:dword;
pAuthIdentityDataCoAuthIdentity;
dwCapabilitiesWORD;
end;
赋值函数
function getAuthInfo(var Fcai:_CoAuthInfo):boolean;
var
fcid:_CoAuthIdentity
wUser,wDomain,wPsw:WideString;
begin
wUser:='whuser';//用户名
wDomain:='192.168.1.6';//远程计算机名
wPsw:='Wanghui123';//密码
FillMemory(@Fcai,sizeof(Fcai),0);
FillMemory(@FCid,sizeof(FCid),0);
// FillMemory(@FSvInfo,sizeof(FSvInfo),0);
with fcid do begin
user:=pUnshort(@wUser[1]);
UserLength:=length(wUser);
Domain:=pUnshort(@wDomain[1]);
DomainLength:=length(wDomain);
password:=pUnshort(@wPsw[1]);
PasswordLength:=length(wPsw);
Flags:=2
//SEC_WINNT_AUTH_IDENTITY_UNICODE
end;
//以上填充_CoAuthIdentity结构
with fcai do begin
dwAuthnSvc:=10;//winNt默认的鉴证服务 RPC_C_AUTHN_WINNT
dwAuthzSvc:=$FFFFFF;//0
//RPC_C_AUTHZ_NONE
//pwszServerPrincName:=pwidechar(wDomain);
dwAuthnLevel:=3;//0;
dwImpersonationLevel:=3;//必须设置成模拟
pAuthIdentityData:=@fcid;
dwCapabilities:=$0;//$0800;
end;
result:=true;
end;
如果我在调用函数中直接放置了getAuthInfo 中包含的代码,程序执行正常。
然而如果我用getauthinfo 取得fcai后面的程序就调用不正常了,但是检查了一下fcai的值两种方法是一样的,真的太奇怪了。
我使用fcai的地方是
with fcai do
CoSetProxyBlanket(iu,dwAuthnSvc,dwAuthzSvc,pwidechar(pAuthIdentityData^.Domain),
dwAuthnLevel,dwImpersonationLevel,pAuthIdentityData,dwCapabilities);
type
//////////////add by wanghui begin
pUnShort=^Word;
pCoAuthIdentity=^_CoAuthIdentity;
_CoAuthIdentity=record
userUnShort;
UserLength:ULONG;
DomainUnShort;
DomainLength:Ulong;
passwordUnShort;
PasswordLength:ulong;
Flags:ulong;
end;
_CoAuthInfo=record
dwAuthnSvcWORD;
dwAuthzSvcWORD;
pwszServerPrincName:WideString;
dwAuthnLevelword;
dwImpersonationLevel:dword;
pAuthIdentityDataCoAuthIdentity;
dwCapabilitiesWORD;
end;
赋值函数
function getAuthInfo(var Fcai:_CoAuthInfo):boolean;
var
fcid:_CoAuthIdentity
wUser,wDomain,wPsw:WideString;
begin
wUser:='whuser';//用户名
wDomain:='192.168.1.6';//远程计算机名
wPsw:='Wanghui123';//密码
FillMemory(@Fcai,sizeof(Fcai),0);
FillMemory(@FCid,sizeof(FCid),0);
// FillMemory(@FSvInfo,sizeof(FSvInfo),0);
with fcid do begin
user:=pUnshort(@wUser[1]);
UserLength:=length(wUser);
Domain:=pUnshort(@wDomain[1]);
DomainLength:=length(wDomain);
password:=pUnshort(@wPsw[1]);
PasswordLength:=length(wPsw);
Flags:=2
//SEC_WINNT_AUTH_IDENTITY_UNICODE
end;
//以上填充_CoAuthIdentity结构
with fcai do begin
dwAuthnSvc:=10;//winNt默认的鉴证服务 RPC_C_AUTHN_WINNT
dwAuthzSvc:=$FFFFFF;//0
//RPC_C_AUTHZ_NONE
//pwszServerPrincName:=pwidechar(wDomain);
dwAuthnLevel:=3;//0;
dwImpersonationLevel:=3;//必须设置成模拟
pAuthIdentityData:=@fcid;
dwCapabilities:=$0;//$0800;
end;
result:=true;
end;
如果我在调用函数中直接放置了getAuthInfo 中包含的代码,程序执行正常。
然而如果我用getauthinfo 取得fcai后面的程序就调用不正常了,但是检查了一下fcai的值两种方法是一样的,真的太奇怪了。
我使用fcai的地方是
with fcai do
CoSetProxyBlanket(iu,dwAuthnSvc,dwAuthzSvc,pwidechar(pAuthIdentityData^.Domain),
dwAuthnLevel,dwImpersonationLevel,pAuthIdentityData,dwCapabilities);