home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
xdsa4.exe
/
DSLIST.C
next >
Wrap
C/C++ Source or Header
|
1995-11-03
|
5KB
|
167 lines
/**************************************************************************
** File: dslist.c
**
** Desc: Lists users on a server and displays their full NDS name
**
**
** DISCLAIMER
**
** Novell, Inc. makes no representations or warranties with respect to
** any NetWare software, and specifically disclaims any express or
** implied warranties of merchantability, title, or fitness for a
** particular purpose.
**
** Distribution of any NetWare software is forbidden without the
** express written consent of Novell, Inc. Further, Novell reserves
** the right to discontinue distribution of any NetWare software.
**
** Novell is not responsible for lost profits or revenue, loss of use
** of the software, loss of data, costs of re-creating lost data, the
** cost of any substitute equipment or program, or claims by any party
** other than you. Novell strongly recommends a backup be made before
** any software is installed. Technical support for this software
** may be provided at the discretion of Novell.
**
**
** Programmers:
**
** Ini Who Firm
** ---------------------------------------------------------------------
** DWH Dirk W. Howard Novell Developer Support
**
**
** History:
**
** When Who What
** ---------------------------------------------------------------------
** 11-3-1995 DWH First code.
**
*/
/**************************************************************************
** Function prototypes and macro definitions
*/
/*------------------------------------------------
** Include headers
*/
#include <stdio.h>
#include <nwconn.h>
#include <nwcntask.h>
#include <nwdsapi.h>
#include <nwmisc.h>
#include <nwbindry.h>
#include <conio.h>
/**************************************************************************
** Main procedure
*/
void main( void )
{
WORD wConnection;
char objectName[48];
WORD objectType;
long objectID;
BYTE loginTime[7];
NWDSContextHandle cx;
NWCONN_HANDLE connID;
char name[MAX_DN_CHARS+1];
NWDSCCODE ccode;
uint32 flags;
BYTE net[4], node[6];
char netBuff[9], nodeBuff[13];
int i;
/*------------------------------------------------
** Create a DS context to work with
*/
cx = NWDSCreateContext();
/*------------------------------------------------
** Get and set the context flags so we can display the names
** in a typeless naming convention and the full name is used.
*/
ccode = NWDSGetContext( cx, DCK_FLAGS, &flags );
if ( ccode )
printf( "Error getting context flags\r\n" );
else
{
flags |= DCV_TYPELESS_NAMES; /* Set the Typeless names flag */
flags &= ~DCV_CANONICALIZE_NAMES; /* Clear the Canonicalize
names flag */
ccode = NWDSSetContext( cx, DCK_FLAGS, &flags );
if ( ccode )
printf( "Error setting context flags.\r\n" );
}
/*------------------------------------------------
** Get a connection other than connection 0 to work on
*/
connID = SetCurrentConnection( -1 );
connID = GetCurrentConnection();
/*------------------------------------------------
** Process each connection
*/
printf( "\r\nUser information\r\n"
"Connection Network Node Address User Name\r\n"
"---------- -------- ------------- -------------------------"
"-------\r\n" );
for ( wConnection=1; wConnection<250; wConnection++ )
{
if ( GetConnectionInformation( wConnection, objectName, &objectType,
&objectID, loginTime ) )
continue; /* on error skip the rest of the loop */
if ( objectID == 0 )
continue; /* if no objectID skip the rest */
if ( objectType != OT_USER )
continue; /* if not a user type skip the rest */
GetInternetAddress( wConnection, net, node );
sprintf( netBuff, "%02X%02X%02X%02X",
net[0], net[1], net[2], net[3] );
/*------------------------------------------------
** Remove leading zeros
*/
for( i = 0; i < 7; i++ )
if (netBuff[i] == '0')
netBuff[i] = ' ';
else
break;
sprintf( nodeBuff, "%02X%02X%02X%02X%02X%02X",
node[0], node[1], node[2], node[3], node[4], node[5] );
/*------------------------------------------------
** Remove leading zeros
*/
for( i = 0; i < 11; i++ )
if (nodeBuff[i] == '0')
nodeBuff[i] = ' ';
else
break;
NWDSMapIDToName( cx, connID, LongSwap(objectID), name );
printf( "%6u [%8.8s] [%12.12s] %s\r\n", wConnection, netBuff,
nodeBuff, name );
}
printf( "\r\n" );
/*------------------------------------------------
** Return connection
*/
ReturnConnection( SetCurrentConnection( 0 ) );
/*------------------------------------------------
** Return the context
*/
NWDSFreeContext( cx );
}