rpcrt4: Add a stub implementation of RpcServerInqDefaultPrincNameA/W.

This commit is contained in:
Hans Leidekker 2012-05-09 12:06:29 +02:00 committed by Alexandre Julliard
parent 1157ccccd7
commit 4d6ff85433
4 changed files with 103 additions and 2 deletions

View File

@ -44,6 +44,7 @@
#include "rpc_message.h"
#include "rpc_defs.h"
#include "ncastatus.h"
#include "secext.h"
WINE_DEFAULT_DEBUG_CHANNEL(rpc);
@ -1457,6 +1458,45 @@ RPC_STATUS WINAPI RpcServerRegisterAuthInfoW( RPC_WSTR ServerPrincName, ULONG Au
return RPC_S_OK;
}
/******************************************************************************
* RpcServerInqDefaultPrincNameA (rpcrt4.@)
*/
RPC_STATUS RPC_ENTRY RpcServerInqDefaultPrincNameA(ULONG AuthnSvc, RPC_CSTR *PrincName)
{
RPC_STATUS ret;
RPC_WSTR principalW;
TRACE("%u, %p\n", AuthnSvc, PrincName);
if ((ret = RpcServerInqDefaultPrincNameW( AuthnSvc, &principalW )) == RPC_S_OK)
{
if (!(*PrincName = (RPC_CSTR)RPCRT4_strdupWtoA( principalW ))) return RPC_S_OUT_OF_MEMORY;
RpcStringFreeW( &principalW );
}
return ret;
}
/******************************************************************************
* RpcServerInqDefaultPrincNameW (rpcrt4.@)
*/
RPC_STATUS RPC_ENTRY RpcServerInqDefaultPrincNameW(ULONG AuthnSvc, RPC_WSTR *PrincName)
{
ULONG len = 0;
FIXME("%u, %p\n", AuthnSvc, PrincName);
if (AuthnSvc != RPC_C_AUTHN_WINNT) return RPC_S_UNKNOWN_AUTHN_SERVICE;
GetUserNameExW( NameSamCompatible, NULL, &len );
if (GetLastError() != ERROR_MORE_DATA) return RPC_S_INTERNAL_ERROR;
if (!(*PrincName = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
return RPC_S_OUT_OF_MEMORY;
GetUserNameExW( NameSamCompatible, *PrincName, &len );
return RPC_S_OK;
}
/***********************************************************************
* RpcServerListen (RPCRT4.@)
*/

View File

@ -427,8 +427,8 @@
@ stdcall RpcServerInqBindings(ptr)
@ stub RpcServerInqCallAttributesA # wxp
@ stub RpcServerInqCallAttributesW # wxp
@ stub RpcServerInqDefaultPrincNameA
@ stub RpcServerInqDefaultPrincNameW
@ stdcall RpcServerInqDefaultPrincNameA(long ptr)
@ stdcall RpcServerInqDefaultPrincNameW(long ptr)
@ stub RpcServerInqIf
@ stdcall RpcServerListen(long long long)
@ stdcall RpcServerRegisterAuthInfoA(str long ptr ptr)

View File

@ -31,6 +31,7 @@
#include "rpc.h"
#include "rpcdce.h"
#include "secext.h"
typedef unsigned int unsigned32;
typedef struct twr_t
@ -854,6 +855,59 @@ static void test_RpcBindingFree(void)
status);
}
static void test_RpcServerInqDefaultPrincName(void)
{
RPC_STATUS ret;
RPC_CSTR principal, saved_principal;
BOOLEAN (WINAPI *pGetUserNameExA)(EXTENDED_NAME_FORMAT,LPSTR,PULONG);
char *username;
ULONG len = 0;
pGetUserNameExA = (void *)GetProcAddress( LoadLibraryA("secur32.dll"), "GetUserNameExA" );
if (!pGetUserNameExA)
{
win_skip( "GetUserNameExA not exported\n" );
return;
}
pGetUserNameExA( NameSamCompatible, NULL, &len );
username = HeapAlloc( GetProcessHeap(), 0, len );
pGetUserNameExA( NameSamCompatible, username, &len );
ret = RpcServerInqDefaultPrincNameA( 0, NULL );
ok( ret == RPC_S_UNKNOWN_AUTHN_SERVICE, "got %u\n", ret );
ret = RpcServerInqDefaultPrincNameA( RPC_C_AUTHN_DEFAULT, NULL );
ok( ret == RPC_S_UNKNOWN_AUTHN_SERVICE, "got %u\n", ret );
principal = (RPC_CSTR)0xdeadbeef;
ret = RpcServerInqDefaultPrincNameA( RPC_C_AUTHN_DEFAULT, &principal );
ok( ret == RPC_S_UNKNOWN_AUTHN_SERVICE, "got %u\n", ret );
ok( principal == (RPC_CSTR)0xdeadbeef, "got unexpected principal\n" );
saved_principal = (RPC_CSTR)0xdeadbeef;
ret = RpcServerInqDefaultPrincNameA( RPC_C_AUTHN_WINNT, &saved_principal );
ok( ret == RPC_S_OK, "got %u\n", ret );
ok( saved_principal != (RPC_CSTR)0xdeadbeef, "expected valid principal\n" );
ok( !strcmp( (const char *)saved_principal, username ), "got \'%s\'\n", saved_principal );
trace("%s\n", saved_principal);
ret = RpcServerRegisterAuthInfoA( (RPC_CSTR)"wine\\test", RPC_C_AUTHN_WINNT, NULL, NULL );
ok( ret == RPC_S_OK, "got %u\n", ret );
principal = (RPC_CSTR)0xdeadbeef;
ret = RpcServerInqDefaultPrincNameA( RPC_C_AUTHN_WINNT, &principal );
ok( ret == RPC_S_OK, "got %u\n", ret );
ok( principal != (RPC_CSTR)0xdeadbeef, "expected valid principal\n" );
ok( !strcmp( (const char *)principal, username ), "got \'%s\'\n", principal );
RpcStringFree( &principal );
ret = RpcServerRegisterAuthInfoA( saved_principal, RPC_C_AUTHN_WINNT, NULL, NULL );
ok( ret == RPC_S_OK, "got %u\n", ret );
RpcStringFree( &saved_principal );
HeapFree( GetProcessHeap(), 0, username );
}
START_TEST( rpc )
{
UuidConversionAndComparison();
@ -867,4 +921,5 @@ START_TEST( rpc )
test_UuidCreate();
test_UuidCreateSequential();
test_RpcBindingFree();
test_RpcServerInqDefaultPrincName();
}

View File

@ -611,6 +611,12 @@ RPCRTAPI unsigned short RPC_ENTRY
RPCRTAPI int RPC_ENTRY
UuidIsNil( UUID* Uuid, RPC_STATUS* Status_ );
RPCRTAPI RPC_STATUS RPC_ENTRY
RpcServerInqDefaultPrincNameA( ULONG AuthnSvc, RPC_CSTR *PrincName );
RPCRTAPI RPC_STATUS RPC_ENTRY
RpcServerInqDefaultPrincNameW( ULONG AuthnSvc, RPC_WSTR *PrincName );
#define RpcServerInqDefaultPrincName WINELIB_NAME_AW(RpcServerInqDefaultPrincName)
#ifdef __cplusplus
}
#endif