Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Supported interfaces in live object
Message
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00391907
Message ID:
00392186
Views:
10
Mike,
Could you start adding the < pre >< /pre > tag around your code. You have indentation, we'd like to see it. *s*

>>>And you don't even need to build it from scratch: http://support.microsoft.com/support/kb/articles/Q192/7/66.ASP?LN=EN-US&SD=gn&FR=0.
>>
>> It doesn't look like it's available for download.
>
>Since the copyright in the article says "Microsoft" and not "Mike Stewart", I'm sure I can't slap the whole thing up on my personal website, but here's the gist of it. Basically, get an ADSI server, and enumerate through the child objects and populate a treeview on the form. Not terribly hard, really. The enumeration code is below. Thisform.text1.value is the name of the server, and the proc takes a treeview node as a parameter (so it knows where to drill down). The code may not make sense outside of the context of the original sample, but maybe it will help, who knows. Hopefully they'll fix the link soon.
>
>*-- Code begins here
>LPARAMETERS NODE
>
>*-- Enable the Stop button
>ThisForm.cmdStop.Enabled = .T.
>
>liCounter = 0 && local child object counter for DOEVENTS
>
>*-- Initialize objects
>oADSobj = NULL
>oCurrentADSobj = NULL
>
>oADSobj = GETOBJECT(ALLTRIM(THISFORM.Text1.VALUE))
>oCurrentADSobj = GETOBJECT(gsPath)
>
>IF THISFORM.Treeview1.Nodes.COUNT = 0 && Treeview is not initialized
> oContainer = oADSobj
>
> *-- Top-level object
> NODE = THISFORM.Treeview1.Nodes.ADD(, , oADSobj.ADSPath, oADSobj.NAME, )
> NODE.TAG = oADSobj.ADSPath+"/"+oADSobj.NAME
> NODE.SORTED = .T.
> Node.Expanded = .T.
>
> FOR EACH CHILD IN oContainer
>
> *-- This could take a while, so give the user a chance to abort
> liCounter = liCounter + 1
> IF liCounter = 50 && Check for every 50 objects
> liCounter = 0
> DOEVENTS
> IF glStop
> ThisForm.cmdStop.Enabled = .F.
> glStop = .F.
> RETURN
> ENDIF
> ENDIF
>
> IF llAll OR (lsUsers $ CHILD.CLASS ;
> OR lsComputers $ CHILD.CLASS ;
> OR lsPrinters $ CHILD.CLASS ;
> OR lsGroups $ CHILD.CLASS ;
> OR lsServices $ CHILD.CLASS)
>
> NodeChild = THISFORM.Treeview1.Nodes.ADD(NODE, 4, , CHILD.CLASS + ": " + CHILD.NAME, )
>
> *-- Store the paths and object name so that we can GETOBJECT() based on information
> *-- in the node.
> NodeChild.TAG = CHILD.ADSPath
> NodeChild.SORTED = .T.
>
> *-- Set up an empty node in case the object is a container
> *-- Check to see if object is a container
> *-- If it is a container, add a placeholder node
> IF Child.Class <> "Schema" && Can't get the schema for a schema
> oSchema = GETOBJECT(CHILD.Schema)
> ELSE
> oSchema = .F.
> ENDIF
> IF VARTYPE(oSchema) = "O"
> IF oSchema.CONTAINER
> ChildNode = THISFORM.Treeview1.Nodes.ADD(NodeChild, 4, , "Empty",)
> ENDIF
> ENDIF && VARTYPE(oSchema) = "O"
> ENDIF && NOT llAll
> ENDFOR && EACH Child IN oContainer
> THISFORM.Treeview1.Nodes(1).Expanded = .T.
>ELSE
> NODE.SORTED = .T.
>
> *-- Check to make sure we even have an object.
> *-- If the network path is not found, oCurrentADSobj will be null.
> IF VARTYPE(oCurrentADSobj) <> "O"
> RETURN
> ENDIF
>
> *-- Check to see if object is a container
> IF oCurrentADSobj.Class <> "Schema" && Can't get the schema for a schema
> oSchema = GETOBJECT(oCurrentADSobj.Schema)
> ELSE
> oSchema = .F.
> ENDIF
>
> IF VARTYPE(oSchema) = "O"
> IF oSchema.CONTAINER
> FOR EACH CHILD IN oCurrentADSobj
>
> *-- This could take a while, so give the user a chance to abort
> liCounter = liCounter + 1
> IF liCounter = 50 && Check for every 50 objects
> liCounter = 0
> DOEVENTS
> IF glStop
> ThisForm.cmdStop.Enabled = .F.
> glStop = .F.
> RETURN
> ENDIF
> ENDIF
> NewNode = THISFORM.Treeview1.Nodes.ADD(NODE, 4, , CHILD.CLASS + ": " + CHILD.NAME,)
> NewNode.TAG = CHILD.ADSPath
> NewNode.SORTED = .T.
>
> *-- Set up an empty node in case the object is a container
> *-- Check to see if object is a container
> *-- If it is a container, add a placeholder node
> IF Child.Class <> "Schema" && Can't get the schema for a schema
> oChildSchema = GETOBJECT(CHILD.Schema)
> ELSE
> oChildSchema = .F.
> ENDIF
> IF VARTYPE(oChildSchema) = "O"
> IF oChildSchema.CONTAINER
> NewChildNode = THISFORM.Treeview1.Nodes.ADD(NewNode, 4, , "Empty",)
> ENDIF
> ENDIF && VARTYPE(oChildSchema) = "O"
> ENDFOR && EACH Child in oCurrentADSobj
> ENDIF && oSchema.Container
> ENDIF && VARTYPE(oSchema) = "O"
>ENDIF && ThisForm.Treeview1.Nodes.Count = 0
>ThisForm.cmdStop.Enabled = .F.
>*-- Code ends here
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform