Page 1 of 1 1
Topic Options
#117620 - 2004-04-09 03:04 PM Conversion COM from VB to Kix 4.21
esun Offline
Fresh Scripter

Registered: 2001-11-09
Posts: 10
Loc: Woburn
Wondering if someone might be willing to guide me with conversion of this script from VB to KIX. I don't get any errors but the user objects do not seem to be getting returned.

The general idea is to get a list of member objects from this eroom api. Once we have the username we can compare to a username from AD, query for the email address and synch it up. The dir connector does not do this automatically.

;Convert from this vb script below
;Dim SvrManager
;Dim Facility
;Dim Room
;dim Member
;Dim Coll
;set SvrManager = CreateObject("Instinctive.ServerManager")
;Set Facility = SvrManager.GetFacility("ArQule_home", "")
;Set Coll = Facility.MemberManager.GetMembers(erMemFlagUsersOnly)
;Dim i
;on error resume next
;For i = 1 To Coll.Count
;Set Member = Coll.Item(i)
;Member.User.eMail=Member.User.LoginName + "@arqule.com"
;'msgbox "email address: " + Member.User.eMail
;Next
;set Facility=Nothing
;Set Coll=Nothing
;END VB

;START KIX
;enemerate a member list
break on
$SvrManager = CreateObject("Instinctive.ServerManager")
$Facility = $SvrManager.GetFacility("ArQule_home", "")
$Coll = $Facility.MemberManager.GetMembers(erMemFlagUsersOnly)
;line above seems to return nothing
? $coll.count
sleep 10
? $coll.item
sleep 10
? "start the loop"
for each $muser in $coll
? $muser.count
? $muser.item
next
? "end the loop"
$Facility=0
$Coll=0

;enumerate the objects from AD(this works will nest when ready)
$objmem = GetObject("LDAP://AXIS/OU=Pfizer,OU=External Users,DC=arqule,DC=com")
for each $user in $objmem
If $user.class = "user"
? $user.samaccountname
? $user.mail
sleep 1
ELSE
ENDIF
next

Thanks for any help, please excuse my lack of scripting skills. I can provide details.





Top
#117621 - 2004-04-09 03:13 PM Re: Conversion COM from VB to Kix 4.21
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Put error checking ,e.g.
Code:
? 'Error '+@ERROR+' - '+@SERROR


after each line and see why it fails.
_________________________
There are two types of vessels, submarines and targets.

Top
#117622 - 2004-04-09 04:01 PM Re: Conversion COM from VB to Kix 4.21
esun Offline
Fresh Scripter

Registered: 2001-11-09
Posts: 10
Loc: Woburn
Thanks for the help

Ok added the error checking need to remember to do this in all of my scripts.

This is the return
following: $Coll = $Facility.MemberManager.GetMembers(erMemFlagUsersOnly)

Error -2147352571 - Type mismatch.

Top
#117623 - 2004-04-09 04:14 PM Re: Conversion COM from VB to Kix 4.21
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
You need to find out the numeric "value" of erMemFlagUsersOnly ... its an ENUM that can viewed in a number of ways ... the easiest way if you know how, is to go into excel or word, then start tools->macro and start the visual basic editor. From there go tools->references and find that COM object. Select it and click OK, then from vb editror go view->object browser. Look for "all libraries" in the object browser combobox, select this component, then sniff around the interface, should be able to find this enum. If you select it, it should show the value in the bottom panel.

Top
#117624 - 2004-04-09 06:12 PM Re: Conversion COM from VB to Kix 4.21
esun Offline
Fresh Scripter

Registered: 2001-11-09
Posts: 10
Loc: Woburn
Thanks was able to find this value it = 4. I am not sure how to incorporate this new information into the code?
Top
#117625 - 2004-04-09 06:16 PM Re: Conversion COM from VB to Kix 4.21
esun Offline
Fresh Scripter

Registered: 2001-11-09
Posts: 10
Loc: Woburn
much appreciated changed the erMemFlagUsersOnly to the number 4. I now return a zero error and get a number for $coll.count.
Top
#117626 - 2004-04-09 08:07 PM Re: Conversion COM from VB to Kix 4.21
esun Offline
Fresh Scripter

Registered: 2001-11-09
Posts: 10
Loc: Woburn
The final Product do I need to release the com objects at the end of the script? Thanks for all of your help

;AD to Eroom email address synch for external PFE users
;E Charlton 4-9-2004

break on
;generate the eroom member list
$SvrManager = CreateObject("eRoom.ServerManager")
$Facility = $SvrManager.GetFacility("ArQule_home", "")
$Coll = $Facility.MemberManager.GetMembers(4)

;generate the objects from AD
$objmem = GetObject("LDAP://ATLAS/OU=Pfizer,OU=External Users,DC=arqule,DC=com")

;check for a match and synch the email address
for each $user in $objmem
IF $user.class = "user"
For $ic = 1 To $Coll.Count
$Member = $Coll.Item($ic)
$vermem = $Member.User.loginname
IF $vermem = $user.samaccountname
$Member.user.email=$user.mail
ELSE
ENDIF
Next $ic
ELSE
ENDIF
Next

Top
#117627 - 2004-04-09 08:15 PM Re: Conversion COM from VB to Kix 4.21
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
It is a best practice to do that. Some COM objects need to be closed explicitly, e.g. Excel.
_________________________
There are two types of vessels, submarines and targets.

Top
#117628 - 2004-04-09 08:30 PM Re: Conversion COM from VB to Kix 4.21
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You could have better performance using a filter instead of:
IF $user.class = "user"

search on the keywords LDAP filter for examples
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#117629 - 2004-04-09 08:34 PM Re: Conversion COM from VB to Kix 4.21
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Also wonder why you have all those ELSE statements with nothing between them and the ENDIF.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#117630 - 2004-04-09 08:45 PM Re: Conversion COM from VB to Kix 4.21
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
So something like this would be much more efficient per Les's suggestions. I was bored....

Code:
break on
;generate the eroom member list
$SvrManager = CreateObject("eRoom.ServerManager")
$Facility = $SvrManager.GetFacility("ArQule_home", "")
$Coll = $Facility.MemberManager.GetMembers(4)

;generate the objects from AD
$objmem = GetObject("LDAP://ATLAS/OU=Pfizer,OU=External Users,DC=arqule,DC=com")
$objmem.Filter = "User",""

;check for a match and synch the email address
for each $user in $objmem
For $ic = 1 To $Coll.Count
$Member = $Coll.Item($ic)
$vermem = $Member.User.loginname
IF $vermem = $user.samaccountname
$Member.user.email=$user.mail
ENDIF
Next
Next


Top
#117631 - 2004-04-09 09:04 PM Re: Conversion COM from VB to Kix 4.21
esun Offline
Fresh Scripter

Registered: 2001-11-09
Posts: 10
Loc: Woburn
I have some bad habits. If/else works so never looked for the right way to do it. Can you show me an example of the better method?

thanks

Top
#117632 - 2004-04-09 09:07 PM Re: Conversion COM from VB to Kix 4.21
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
"Bored to tears" Shane already did.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#117633 - 2004-04-09 09:11 PM Re: Conversion COM from VB to Kix 4.21
esun Offline
Fresh Scripter

Registered: 2001-11-09
Posts: 10
Loc: Woburn
Thanks all extremely helpful, I normally bounce my head against the wall for a few weeks, search the board for help until I finally figure it out.
Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 242 anonymous users online.
Newest Members
SERoyalty, mytar, Gabriel, Alex_Evos, Dansen
17869 Registered Users

Generated in 0.07 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org