WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

NetwareX Extender

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Create a List of Workstations

Keywords: 	  List Workstation Netware

Question:

How do I create a list of workstations that are in NDS. I'm creating a Zen4RC console for my users and I need to get workstations that live under the object unit 'Workstations' and or get a list of members of a workstation group. Can either be done with the NetwareX extender. If so, how?

Answer:

You will need to use either nwListObjects() or nwSearchObjects() enumerate objects of a specific class in NDS. Just determine the object class name for a workstation object and then feed that as an input parameter to either of those functions along with a container location and you will get @TAB delimited list returned to you containing all of the names of objects which are of that object class.
AddExtender('WWNWX34I.DLL')
; Set the script's current context to the root of the tree - this will return object names with their full context.
nwSetContext(0,'[Root]','') 

; Turn off minor runtime error displaying ONLY FOR THE NEXT FUNCTION - just in case context or options are bad or search results fail.
ErrorMode(@OFF) 

; find any Workstation classed objects across entire tree (you can be much more specific if you like.
WkstList = nwSearchObjects("[Root]","","Workstation",2,"") 

; capture any error codes if they exist
RC = LastError() 

; TURN ERROR HANDLING BACK ON !!! - Very important! or your entire script might not EXIT or report if there is something wrong. 
ErrorMode(@CANCEL) 

WkstCount = ItemCount(WkstList,@TAB)
if WkstCount == 0
	Message("Whoops - Nothing found",RC) 
else
	object = AskItemList("Found %WkstCount% Workstations", WkstList, @TAB, @unsorted, @single)

	; The next bit of code is ripped out of the example from the NetwareX extender Help file for the nwGetObjValue function.
	; You should be able to work out how to get almost any info about the Workstation object that is in NDS e-directory with this.

	attribs = nwGetObjValue(object,'','','',2)

	:PickAttrib

	attrib = ItemExtract(1,ItemSelect(StrCat('Attributes for "',object,'"'),attribs,@TAB),'|')
	if (attrib == '') then goto PickObject

	; Set the flag to get full object information.
	flag = 1
	values = nwGetObjValue(object,attrib,"","",flag)
	BinBufSize = nwGetObjValue(object,attrib,-1,-1,flag)
	if (BinBufSize == 0)
		Message(StrCat('Attribute "',attrib,'"'),'Zero length for attribute value(s)')
		if (FileExist('BinBuf1.txt'))
			FileDelete('BinBuf1.txt')
		endif
	else
		BinBuf = BinaryAlloc(BinBufSize)
		Temp = nwGetObjValue(object,attrib,IntControl(42,BinBuf,0,0,0),BinBufSize,flag)
		BinaryEODSet(BinBuf,Temp)
		BinaryWrite(BinBuf,"BinBuf1.txt")
		BinaryFree(BinBuf)
		Drop(BinBuf)
		Message(StrCat('Attribute "',attrib,'"'),StrCat('Binary buffer size = ',BinBufSize,', retrieved bytes = ',Temp))
		Drop(BinBufSize,Temp)
	endif

	; Display the values that were retrieved.
	ItemSelect(StrCat('Attribute = "',attrib,'", flag = ',flag), values, @TAB)

	; Set the flag to get basic object information that is formatted
	; similar to what the old n4ObjProps() function used to provided.
	flag = 0
	values = nwGetObjValue(object,attrib,"","",flag)
	BinBufSize = nwGetObjValue(object,attrib,-1,-1,flag)
	if (BinBufSize == 0)
		Message(StrCat('Attribute "',attrib,'"'),'Zero length for attribute value(s)')
		if (FileExist('BinBuf2.txt'))
			FileDelete('BinBuf2.txt')
		endif
	else
		BinBuf = BinaryAlloc(BinBufSize)
		Temp = nwGetObjValue(object,attrib,IntControl(42,BinBuf,0,0,0),BinBufSize,flag)
		BinaryEODSet(BinBuf,Temp)
		BinaryWrite(BinBuf,"BinBuf2.txt")
		BinaryFree(BinBuf)
		Drop(BinBuf)
		Message(StrCat('Attribute "',attrib,'"'),StrCat('Binary buffer size = ',BinBufSize,', retrieved bytes = ',Temp))
		Drop(BinBufSize,Temp)
	endif
	; Display the values that were retrieved.
	ItemSelect(StrCat('Attribute = "',attrib,'", flag = ',flag), values, @TAB)
	goto PickAttrib
endif
exit

Article ID:   W16053
File Created: 2004:03:30:15:42:38
Last Updated: 2004:03:30:15:42:38