Solved

create a list of users and contexts

Posted on 1998-10-14
7
319 Views
Last Modified: 2008-02-20
Hi,
  I would like to be able to create a text file which lists all of the userids and contexts in a Directory.  I tried doing this with cx, but it doesn't seem to list the user objects.  Any idea?  If there are any inexpensive third party utilities that can do this, I am interested.
  Many Thanks,
Jeremy
0
Comment
Question by:jshafer
  • 3
  • 3
7 Comments
 

Author Comment

by:jshafer
Comment Utility
(Oh yes, I am using NW 4.1)
0
 

Expert Comment

by:jtest
Comment Utility
I have code that allows me to list all users, with contexts, on a given Intranetware 4 server.  Is this what you are looking for? It uses the NW* calls in CLXWin32.Dll.

Can't get it until tomorrow, but let me know if this is useful.


0
 

Author Comment

by:jshafer
Comment Utility
Yes, that would be very helpful.  I presume these are VB routines?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 3

Accepted Solution

by:
brosenb0 earned 100 total points
Comment Utility
You can create a text file that lists every user, in all contexts from the [root] down by using the Novell supplied utility NList.Exe, found in Sys:Public.

Type the following: NList user /R /S >MyFile.Txt

Type NList /? for help
0
 

Expert Comment

by:jtest
Comment Utility
Sorry, I've been away unexpectedly.  If brosenb0 ans. isn't enough, I'll try to upload some VB code next week.
0
 

Expert Comment

by:jtest
Comment Utility
'Here's code that works for me...it lists all the servers in the
'debug window, getting their connection numbers...
'then matches one server name against a name you put in
'via an InputBox, and lists the active users on that server.
'Of course, you'll want to change the public const
' UserServerNameDefault to something on your system.
'Note: nConnMaxUsed on my system reports a number below
'the actual number of connections sometimes, so I've used
'the arbitrary figure of 250 max connections.
'
'Of course, this goes into a .bas module.  You don't need
'a form as long as sub Main is set as the default startup.

'I didn't wait to see if you rejected brosenb0's ans...
'I figure info exchange is more important than points.


Option Explicit
'UserIDs ... minimal code to get list of users

Declare Function NWCallsInit Lib "calwin32" _
   (notUsed1 As Any, notUsed2 As Any) As Long

Declare Function NWCCScanConnRefs Lib "CLXWIN32" _
   (scanIterator As Long, connRef As Long) As Long

Declare Function NWCCGetConnRefInfoString Lib "CLXWIN32" _
   Alias "NWCCGetConnRefInfo" (ByVal connRef As Long, _
   ByVal infoType As Long, _
   ByVal infoLen As Long, _
   ByVal buffer As String) As Long
   
Declare Function NWCCOpenConnByRef Lib "CLXWIN32" _
   (ByVal connRef As Long, _
   ByVal openState As Long, _
   ByVal Reserved As Long, _
         connHandle As Long) As Long
     
Declare Function NWGetFileServerInformation Lib "calwin32" ( _
        ByVal conn As Long, _
        ByVal serverName As String, _
        majorVer As Byte, _
        minVer As Byte, _
        rev As Byte, _
        maxConns As Integer, _
        maxConnsUsed As Integer, _
        connsInUse As Integer, _
        numVolumes As Integer, _
        SFTLevel As Byte, _
        TTSLevel As Byte) As Long

Declare Function NWGetConnectionInformation Lib "calwin32" ( _
   ByVal conn As Long, _
   ByVal connNum As Integer, _
   ByVal objName As String, _
   objType As Integer, _
   objID As Integer, _
   loginTime As Byte) As Long
   
Declare Function NWCCCloseConn Lib "CLXWIN32" _
   (ByVal connHandle As Long) As Long
   
Public Const SUCCESS As Long = &H0
   
Public Const NWCC_TRAN_TYPE_IPX = 1
Public Const NWCC_TRAN_TYPE_UDP = 2
Public Const NWCC_TRAN_TYPE_DDP = 3
Public Const NWCC_TRAN_TYPE_ASP = 4

Public Const NWCC_OPEN_LICENSED = 1
Public Const NWCC_OPEN_UNLICENSED = 2

Public Const NWCC_INFO_SERVER_NAME = 7
Public Const NW_MAX_SERVER_NAME_LEN As Long = 49
 
Public Const NetConnMax = 250
'max licensed conns to search
'...nConnMaxUsed...seems to be too low for me...
'change server name to your default
Public Const UserServerNameDefault = "MHS_MEDIA"
Public UserServerName$
Public UserServerConnRef As Long

Public Sub ListServers()
' Get connected servers
Dim lRet&, lIterator&, lConnRef&, lTemp&
Dim sBuff As String * NW_MAX_SERVER_NAME_LEN
Dim sSrvName As String
Do
   ' lIterator is initialized to zero automatically
   lRet = NWCCScanConnRefs(lIterator, lConnRef)
   If lRet <> SUCCESS Then Exit Do
   lRet = NWCCGetConnRefInfoString( _
      lConnRef, _
      NWCC_INFO_SERVER_NAME, _
      NW_MAX_SERVER_NAME_LEN, _
      sBuff)
   
   If lRet = SUCCESS Then
      lTemp = InStr(1, sBuff, vbNullChar)
      sSrvName = Left(sBuff, lTemp - 1)
      Debug.Print sSrvName
     
      If UCase(sSrvName) = UCase(UserServerName) Then _
         UserServerConnRef = lConnRef
   End If
Loop
End Sub

Private Sub ListUsers()
Dim i%, i1%, i2%, i3%
Dim hConn&, nConnRef&, objID%, nRetcode&
Dim nConnMaxUsed%, objType%
Dim strServerName As String * NW_MAX_SERVER_NAME_LEN
Dim strBuffer As String * 255
Dim strUserName As String, sTemp As String
Dim loginTime(7) As Byte
Dim b1 As Byte, b2 As Byte, b3 As Byte, b4 As Byte, b5 As Byte

nConnRef = UserServerConnRef 'the one selected by the user
nRetcode = NWCCOpenConnByRef(nConnRef, NWCC_OPEN_LICENSED, NWCC_TRAN_TYPE_IPX, hConn)
If nRetcode = SUCCESS Then
   nRetcode = NWGetFileServerInformation( _
      hConn, strBuffer, b1, b2, b3, i1, nConnMaxUsed, i2, i3, b4, b5)
   If nRetcode = SUCCESS Then
      '?? nConnMaxUsed seems to be less than needed sometimes...
      '   so use arbitrarily high number...
      For i = 0 To NetConnMax    'normal use: nConnMaxUsed here
         nRetcode = NWGetConnectionInformation(hConn, i, strBuffer, objType, objID, loginTime(0))
         If nRetcode = SUCCESS Then
            strBuffer = Left$(strBuffer, InStr(1, strBuffer, vbNullChar) - 1)
            strUserName = RTrim(strBuffer)
            Debug.Print strUserName
         End If
      Next i
   End If
   NWCCCloseConn (hConn)
End If
End Sub

Sub Main()
Dim lRetCode As Long
lRetCode = NWCallsInit(0, 0)
If lRetCode <> SUCCESS Then
   MsgBox "Unable to initialize NWCallsInit", _
      vbInformation, "Startup Problem"
   End
End If
UserServerName = InputBox("Server Name for UserList", _
   "Enter Server Name", UserServerNameDefault)
   
ListServers
ListUsers
Stop

End Sub


0
 

Author Comment

by:jshafer
Comment Utility
This comment is for jtest.  Thanks for your post.  I ended up giving the points to brosenbo since he give me the response I really needed.  I tried the your code, and it gives me a list of connected users, what I was really hunting for was a list of all users and their contexts.

I do really like your code though, and wanted to say thanks for it.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now