Solved

create a list of users and contexts

Posted on 1998-10-14
7
326 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
ID: 1593726
(Oh yes, I am using NW 4.1)
0
 

Expert Comment

by:jtest
ID: 1593727
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
ID: 1593728
Yes, that would be very helpful.  I presume these are VB routines?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Accepted Solution

by:
brosenb0 earned 100 total points
ID: 1593729
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
ID: 1593730
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
ID: 1593731
'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
ID: 1593732
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

809 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