This code demonstrates how to get a directory entry name in a different namespace via NWGetNameSpaceEntryName()
#include <nwbindry.h>
#include <nwclxcon.h>
#include <nwconn.h>
#include <nwcntask.h>
#include <nwnspace.h>
#include <nwserver.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFFER_SIZE 256
int main( int argc, char* argv[]) {
char* server_name;
char* user_name;
char* password;
char* entry_name;
NWRCODE rcode;
NWCCODE ccode;
NWCONN_HANDLE conn_handle;
WORD fs_id;
unsigned char buffer[ BUFFER_SIZE];
if ( argc != 5) {
puts( "Syntax: GETNSENT <servername> <username> <password> <entry_name>");
return EXIT_FAILURE;
}
server_name = *++argv;
user_name = *++argv;
password = *++argv;
entry_name = *++argv;
rcode = NWCCOpenConnByName( 0,
server_name,
NWCC_NAME_FORMAT_BIND,
NWCC_OPEN_LICENSED,
NWCC_TRAN_TYPE_WILD,
&conn_handle);
if ( rcode != 0) {
printf( "NWCCOpenConnByName failed, rcode = %x", rcode);
return EXIT_FAILURE;
}
ccode = NWLoginToFileServer( conn_handle, user_name, OT_USER, password);
if ( ccode != 0) {
printf( "NWLoginToFileServer failed, ccode = %x", ccode);
NWCCCloseConn( conn_handle);
return EXIT_FAILURE;
}
ccode = ( NWCCODE) GetFileServerID( server_name, &fs_id);
if ( ccode != 0) {
printf( "GetFileServerID failed, ccode = %x", ccode);
NWCCCloseConn( conn_handle);
return EXIT_FAILURE;
}
SetCurrentFileServerID( fs_id);
printf( "GetCurrentFileServerID returns %d\n", GetCurrentFileServerID());
ccode = ( NWCCODE) NWGetNameSpaceEntryName(( BYTE*) entry_name, 4, BUFFER_SIZE, buffer);
if ( ccode != 0) {
printf( "NWGetNameSpaceEntryName failed, ccode = %x", ccode);
NWCCCloseConn( conn_handle);
return EXIT_FAILURE;
}
puts(( char*) buffer);
NWCCCloseConn( conn_handle);
return EXIT_SUCCESS;
}
© 2008 Novell, Inc. All Rights Reserved.