Hans Leidekker : rpcrt4: Add a stub implementation of RpcServerInqDefaultPrincNameA/W.
Alexandre Julliard
julliard at winehq.org
Wed May 9 13:46:18 CDT 2012
Module: wine
Branch: master
Commit: 4d6ff8543394981a34014f0359d4953c145fa1e7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4d6ff8543394981a34014f0359d4953c145fa1e7
Author: Hans Leidekker <hans at codeweavers.com>
Date: Wed May 9 12:06:29 2012 +0200
rpcrt4: Add a stub implementation of RpcServerInqDefaultPrincNameA/W.
---
dlls/rpcrt4/rpc_server.c | 40 +++++++++++++++++++++++++++++++++
dlls/rpcrt4/rpcrt4.spec | 4 +-
dlls/rpcrt4/tests/rpc.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++
include/rpcdce.h | 6 +++++
4 files changed, 103 insertions(+), 2 deletions(-)
diff --git a/dlls/rpcrt4/rpc_server.c b/dlls/rpcrt4/rpc_server.c
index 6fd1a7b..91b7707 100644
--- a/dlls/rpcrt4/rpc_server.c
+++ b/dlls/rpcrt4/rpc_server.c
@@ -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.@)
*/
diff --git a/dlls/rpcrt4/rpcrt4.spec b/dlls/rpcrt4/rpcrt4.spec
index ac590bf..4b5b553 100644
--- a/dlls/rpcrt4/rpcrt4.spec
+++ b/dlls/rpcrt4/rpcrt4.spec
@@ -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)
diff --git a/dlls/rpcrt4/tests/rpc.c b/dlls/rpcrt4/tests/rpc.c
index d914c97..739a00e 100644
--- a/dlls/rpcrt4/tests/rpc.c
+++ b/dlls/rpcrt4/tests/rpc.c
@@ -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();
}
diff --git a/include/rpcdce.h b/include/rpcdce.h
index bbdc42f..84f6330 100644
--- a/include/rpcdce.h
+++ b/include/rpcdce.h
@@ -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
More information about the wine-cvs
mailing list