FAQ for the NWTP API ==================== B01. How am I knwon at the server ? B02. How do I give someone Console Operator rights ? C01. How can I reset the servertime ? C02. How can I synchronize the workstation's time to that of the server ? L01. How can I place a limit on the number of concurrent users of my program ? (licensing) M01. How can I send a message to another user ? S01. How do I determine whether or not I'm logged into a server ? S02. Is the shell installed ? S03. What is the name of the server I'm logged into ? ******************************** Answers ******************************** B01. What name do I have ? -------------------------- A: You are known at the server by two names: a short (object) name (i.e. the name you use to login) and a full name stored in the bindery. Var SecurityLevel:Byte; ObjectID:Longint; ObjectType:Word; ObjectName,LongName:String; begin GetBinderyAccessLevel(SecurityLevel,ObjectID); GetBinderyObjectname(ObjectID,ObjectName,ObjectType); writeln('You''re known to the server as:',ObjectName); GetRealUserName(ObjectName,LongName); writeln('And to the supervisor as:',LongName); if LongName='' then writeln(''); end. B02. How do I give someone Console Operator rights? --------------------------------------------------- A: You'll have to add the ObjectID of the target user to the OPERATORS property of the supervisor object in the bindery. Note that having console operator rights differs significantly from being supervisor equivalent. Console operator rights allow the user to perform actions from a workstation that could also be done on the server console. Var UserName:string; begin UserName='Goofy'; IF NOT CreateProperty('SUPERVISOR',OT_USER,'OPERATORS', BF_SET or BF_STAT_OBJ, BS_LOGGED_READ or BS_SUPER_WRITE) then if nwBindry.result<>$ED { property already exists } then begin writeln('Error creating operators property.'); Halt(1); end; IF AddBinderyObjectToSet('SUPERVISOR',OT_USER,'OPERATORS', UserName,OT_USER) then writeln('User ',UserName,' is now a console operator.'); end. C01. How can I reset the servertime ? ------------------------------------- A: Use the SetFileServerDateAndTime function in the nwServ unit. In order for this call to be successful, you have to either be the supervisor or have console operator privileges. Var newTime:TnovTime; begin WITH newTime do begin year:=94; month:=6; day:=1; hour:=5; min:=0; sec:=0; end; IF NOT SetFileServerDateAndTime(newTime) then writeln('You need to have console operator rights.'); end. C02. How can I synchronize the workstation's time to that of the server ? ------------------------------------------------------------------------- A: Use Pascal's SetTime and SetDate functions in combination with the GetFileServerDateAndTime function. Var time:TnovTime; year:word; begin GetFileServerDateAndTime(time); if time.year<80 then year:=2000+time.year else year:=1900+time.year; setdate(year,time.month,time.day); settime(time.hour,time.minute,time.second,0); end. L01. How can I place a limit on the number of concurrent users of my program ? ------------------------------------------------------------------------------ A: Use the semaphore functions in the nwSema unit. Note that these enable you to limit the number of concurrent users on a server basis. When a user is refused access because the limit for his current fileserver is exceeded, he can simply login to another fileserver (if available) and try to use the program there. Limiting the number of concurrent users on multiple servers in an internetwork is quite a problem: Novell doesn't provide a method to synchronize semaphore values between servers. CONST INITIAL_SEMAPHORE_VALUE=10; { suppose a licence for 10 concurrent users } SEMAPHORE_NAME='YourProgramName'; { anything goes, as long as it's unique. Max. 128 characters.} VAR openCount :Word; semValue :Integer; semHandle :LongInt; BEGIN {main} { Open Semaphore } semValue := INITIAL_SEMAPHORE_VALUE; { Need in case we're creating the semaphore } IF NOT OpenSemaphore( SEMAPHORE_NAME, semValue, semHandle, openCount ) then begin writeln('Error opening semaphore. error #',nwSema.Result); Halt(1); end; { Wait on the Semaphore (get permission to use the program) } IF NOT WaitOnSemaphore( semHandle, 0 ) then begin if ( nwSema.Result = $FE ) then begin writeln( 'Sorry, license exceeded. Please try again later.' ); halt(1); end else begin writeln('WaitOnSemaphore returned eror# ',nwSema.result); halt(1); end; end; { <===== INSERT YOUR to be licensed PROGRAM HERE =====> } { Signal Semaphore (that we're through with the program) } SignalSemaphore( semHandle ); { Close Semaphore } CloseSemaphore( semHandle ); end. M01. How can I send a message to another user ? ----------------------------------------------- A: Use the SendMessageToUser function in the nwMess unit. This function allows you to send a message to a user or to the members of a group. If there are more than 64 members in the group, only the first 64 members of the group will receive the message due to the way this function is implemented on the server. var name : string; message : string; begin name := 'MBRAMWEL'; message := 'Hi Mark, how is it going?'; SendMessageToUser(name,message); SendMessageToUser('FINANCE_DEPT','Hand over the money..'); SendMessageToUser('*','Goodmorning'); end. Note that unlike the messages broadcasted by the SEND utility, the source of the message is not automatically put in the message itself. S01. How do I determine whether or not I'm logged into a server ? ----------------------------------------------------------------- A: Use the nwBindr IsUserLoggedOn function. S02. Is the shell installed ? ---------------------------------------------- A: Use the nwBindy IsShellLoaded function or query the variables NETX_EXE_Loaded or VLM_EXE_Loaded. (see nwIntr) S03. What is the name of the server I'm logged into ? ----------------------------------------------------- A: If you already know that you're logged in: Var ConnId:Byte; ServerName:string; begin GetEffectiveConnectionID(ConnId); IF GetFileserverName(connId,ServerName) then Writeln('You''re logged into server :',ServerName); end.