We help IT Professionals succeed at work.

Network File Log

mattlaver
mattlaver asked
on
Hi,

Is there a way of logging User ID and date/times of files that have been viewed via a network?

(Bit Big Brother I know...)

Thanks

Matt
Comment
Watch Question

Commented:
Accessing Netware Usernames

You can try this code. I've been using it on a Netware LAN for some time now with no problems. It depends on having the NWCALLS.DLL library already on the
users machine; if users have a Netware connection, then they should already have that DLL.

unit GetLogin;

{This unit is a wrapper for several external functions in the NWCALLS.DLL}
{Adapted by Ray Buck from code written by Gregory Trubetskoy}
{The unit contains a function that returns the Netware User ID}
{and one that returns the user's full name.}

interface
 uses
  SysUtils, Messages, Dialogs;

function GetUserLogin: string;
function GetUserFullName( SomeUser: string): string;

implementation
  type
    NWTimeStamp = record
      Year:      byte;
      Month:     byte;
      Day:       byte;
      Hour:      byte;
      Minute:    byte;
      Second:    byte;
      DayOfWeek: byte;
    end;

  {Netware API's - require NWCALLS.DLL}
  function NWGetDefaultConnectionID(var Connection: word): word; far; external 'NWCALLS';
  function NWGetConnectionNumber(Connection: word; var ConnectionNumber: word): word;
           far; external 'NWCALLS';
  function NWGetConnectionInformation(Connection: word;
                                      ConnectionNumber: word;
                                      ObjectName: pchar;
                                      var ObjectType: word;
                                      var ObjectID: word;
                                      var LoginTime: NWTimeStamp):word;
                                      far; external 'NWCALLS';
  function NWReadPropertyValue(Connection:       word;
                               ObjectName:       pChar;
                               ObjectType:       word;
                               PropertyName:     pChar;
                               DataSetIndex:     byte;
                               DataBuffer:       pChar;
                               var More:             byte;
                               var Flags:            byte): word;
                               far; external 'NWCALLS';

  { end of Netware API stuff }

function GetUserLogin: string;
  var
  ConnectionID: word;
  ConnectionNumber: word;
  RC: word;
  Name: array[0..50] of Char;
  ObjectType: word;
  ObjectID: word;
  LoginTime: NWTimeStamp;

begin
  RC := NWGetDefaultConnectionID(ConnectionID);
  RC := NWGetConnectionNumber(ConnectionID, ConnectionNumber);
  RC := NWGetConnectionInformation( ConnectionID,
                                    ConnectionNumber,
                                    Name,
                                    ObjectType,
                                    ObjectID,
                                    LoginTime);
  Result := StrPas(Name);
end;

function GetUserFullName( SomeUser: string): string;
{The real user name is a 'property' called 'IDENTIFICATON'.
You have to call NWReadPropertyValue passing it (among other things) your ConnectionID,
the name of the object (same as the login of the user who's full name you need)
and the name property you want to retrieve, in this case 'IDENTIFICATION'
(which translated from Novellish to English means 'Full Name').}

var
  ConnectionID: word;
  RC: word;
  Name: array[0..50] of Char;
  ObjectType: word;
  PropName: array[0..14] of Char;
  DataSetIndex: byte;
  FullName: array[0..127] of Char;
  More: byte;
  Flags: byte;

begin
  RC := NWGetDefaultConnectionID(ConnectionID);
  ObjectType := 256; {user}
  StrPCopy(PropName, 'IDENTIFICATION');
  DataSetIndex := 1;
  StrPCopy(Name, SomeUser);
  RC := NWReadPropertyValue( ConnectionID,
                               Name,
                               ObjectType,
                               PropName,
                               DataSetIndex,
                               FullName,
                               More,
                               Flags);
  if RC = 35324 then
    MessageDlg('No user ' + SomeUser + ' exists on this server!',
                mtError, [mbOK], 0);
  Result := StrPas(FullName);
end;

end.
mattlaver:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
CERTIFIED EXPERT

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

accept ginsonic's comment as answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Thanks,

geobul
EE Cleanup Volunteer

Explore More ContentExplore courses, solutions, and other research materials related to this topic.