Page 1 of 2 12>
Topic Options
#85866 - 2002-06-02 07:45 AM GetInfoEx COM Bug? (Help with GetInfoEX)
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I was translating my Perl LookupMailboxesFromAccount.exe to KiXtart and have run into a problem with GetInfoEX. I can not seem to to pass the proper data type to the function. See the somewhat working code below. I need to use GetInfoEx to obtain the "Home-MDB" property that is the actual server location of a mailbox.

You will see the problem line in GetMailBoxProperties($AdsPath) below.
code:
$ExchangeServer="YourServer"
$Domain="YourDomain"
$Account="YourAccount"

$Mailboxes = ADOQueryAssocNTAccount($ExchangeServer, LookupHexSid($Domain, $Account))

? "Mailboxes for " + $Domain + "\" + $Account
? "------------------------------------------------------------------"
for each $mailbox in $MailBoxes
GetMailBoxProperties($Mailbox)
? "------------------------------------------------------------------"
next



Function LookupHexSid($Domain, $Account)
Dim $ADsPath, $ADsSid
$ADsPath = "WinNT://" + $Domain + "/" + $Account
$ADsSid = createobject("ADsSid")
$ADsSid.setas(5,$ADsPath)
$LookupHexSid = $ADsSid.getas(1)
EndFunction


Function ADOQueryAssocNTAccount($ExchangeServer, $HexSid)
Dim $ADOconn, $ADOQueryString, $objRS, $A, $i
$ADOconn = CreateObject("ADODB.Connection")
$ADOConn.Provider = "ADSDSOObject"
$ADOConn.Open()
if @ERROR
exit @ERROR
endif
$ADOQueryString = "<LDAP://$ExchangeServer>;(&(objectClass=person)(Assoc-NT-Account=$HEXsid));adspath;subtree";
$objRS = $ADOconn.Execute($ADOQueryString)
if VarType( $objRS ) <> 0
$i=0
Do
ReDim Preserve $A[$i]
;? $objRS.Fields("adspath").value
$A[$i] = $objRS.Fields("adspath").value
$objRS.movenext
$i=$i+1
until $objRS.EOF
$ADOQueryAssocNTAccount=$A
else
? "No MailBoxes found!"
endif
exit 0;
EndFunction


Function GetMailBoxProperties($AdsPath)
Dim $objMailBox
Dim $A[1]
$objMailBox = GetObject($ADsPath)
? "Display Name: " $objMailBox.get("cn")
? " Given Name: " $objMailBox.get("givenname")
? " Last Name: " $objMailBox.get("sn")
? " Alias: " $objMailBox.get("uid")
? "Primary SMTP: " $objMailBox.get("mail")
? " RDN: " $objMailBox.get("rdn")
? " Home MTA: " $objMailBox.get("home-mta")

; Help Please
; How does pass the required array to GetInfoEdx ???
$objMailBox.GetInfoEx("home-mdb", 0);
? "Using Text: @error @serror"
$A = "home-mdb",""
$objMailBox.GetInfoEx($A, 0);
? "Using Array: @error @serror"
? " Home MDB: " $objMailBox.get("home-mdb")

?
;? "Other Mailboxes:"
;$array=$objMailBox.get("othermailbox")
;for each $item in $array
; $type=substr($item,1,instr($item,"$$")-1)
; $address=substr($item,len($type)+2,len($item))
; ? " " $type ": "$address
;next

EndFunction



[ 03 June 2002, 22:07: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#85867 - 2002-06-02 06:13 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Howard, unable to try this here, but are your getting an error and if so, whats the message ?

-Shawn

Top
#85868 - 2002-06-02 07:05 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Howard,

Not at work..

Maybe a link or two below may help?

http://www.crackinguniversity2000.it/DevGuide/exchange.htm

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/adsi/iads_getinfoex.asp

http://www.crackinguniversity2000.it/DevGuide/advanced.htm

http://www.microsoft.com/mspress/books/sampchap/4477c.asp

http://www.winnetmag.com/Articles/Print.cfm?ArticleID=9168

HTH,

- Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#85869 - 2002-06-02 10:00 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Shawn,

This is all that @error and @serror return. I make two attempts in my code as posted. The first with text and the second with a Kix array.

Using Text: 1 COM exception error "GetInfoEx" (Active Directory - Unspecified error
) [1/1]
Using Array: 1 COM exception error "GetInfoEx" ((null) - (null)) [1/1]
Home MDB:

This is what VB uses: x.GetInfoEx Array("givenName", "sn"), 0

I can this easily in Perl as: $objMailbox->GetInfoEx(["Home-MDB"], 0);

But KiXtart just doesn't seem to work.

[ 02 June 2002, 22:04: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#85870 - 2002-06-02 10:56 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
What if you ask for two items, instead of trying to fake-out an array with a trailing "". eg:

$A = "home-mdb","sn"
$objMailBox.GetInfoEx($A, 0);

Top
#85871 - 2002-06-02 11:28 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Same result using: $A="home-mdb","sn"
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#85872 - 2002-06-03 03:30 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Could this have to do with the whole (support or lack of support for the) multidimensional array issue?

Brian

Top
#85873 - 2002-06-03 03:40 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I'm trying to play catch-up here. BTW, thanks Howard for looking at this.

As a side-note to anyone trying this from home, or probably more appopriate, from work... This does require the ADsSecurity.dll in order to associate the NT account with a SID.

Does the GetInfoEx have anything to do with this: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/ad/optimization_using_getinfoex.asp

Top
#85874 - 2002-06-03 03:57 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Chris, Howard, et al:

I was looking at this snippet of code that Chris pointed to, whats up with this, it assigns an array, then assigns a variable to point to the array (which using vbs, i thought would have been the same thing) ? :

' Initialize the array of properties to pass to GetInfoEx
PropArray = Array("description", "distinguishedName")

' Make the array a single variant for passing to GetInfoEx
Prop = PropArray

Might want to give it a try Howard but not holding my breath [Wink]

-Shawn

Top
#85875 - 2002-06-03 03:59 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I have to use GetInfoEx because the property "Home-MDB" is not in the property cache by default. The problem here seems to be that KiXtart can not passed the array data type that GetInfoEx needs. Maybe the KiXtart syntax for the COM call needs to be altered or Ruud may need to look at this particular COM usage.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#85876 - 2002-06-03 04:09 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Shawn, the statement $A = Array("z","x") naturely causes a script error.

$A = "z","x"
$B = $A
then to GetInfoEx also fails.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#85877 - 2002-06-03 04:11 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Have you tried this:
code:
Dim $A[2]
$A[0] = "z"
$A[1] = "x"
$B = $A

_________________________
There are two types of vessels, submarines and targets.

Top
#85878 - 2002-06-03 04:21 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
When using sealeopard's suggestion the following is generated:

1 COM exception error "GetInfoEx" (Active Directory - The Active Directory datatype cannot be converted to/from a native DS datatype

This is for

using $A directly and for using $B where $B=$A.

[ 03 June 2002, 16:22: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#85879 - 2002-06-03 04:22 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
What if you dim it like this:

Dim $A[1]

-Shawn

[ 03 June 2002, 16:23: Message edited by: Shawn ]

Top
#85880 - 2002-06-03 06:35 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Howard, it also seems that the "No Mailboxes Found" part of your ADOQueryAssocNTAccount function isn't working properly. If I query an NT account without a mailbox it still runs the GetMailBoxProperties function. This returns a "Script Error : unknown command !" error.

I think if you check the value of the property for a nul value you can get around this (in the GetMailBoxProperties function):

code:
if $objMailBox.get("rdn") <> ""
? "You have a mailbox"
else
? "You don't have a mailbox"
endif


Top
#85881 - 2002-06-03 07:55 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Shawn, already tried that one. I think this is either a strong deficiency or bug in KixTart COM.

Chris, it was working in a previous version before I used functions. I will fix it before it is published as "Working Code"
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#85882 - 2002-06-03 08:19 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Howard, do you mean to say that this array problem worked in a previous version ?

About the problem, yeah, you might have found another one of those COM Quirks. Remember the other that was found Howard, I think you were "in on it" - it had to do with the enumeration of WinInstaller objects - and it was identified and fixed as part of Kixtart 4.10. Maybe this is just one of those things - the problem I guess, is to reduce your script into something that Ruud can repro - unless he has all this Exchange Server stuff setup.

Top
#85883 - 2002-06-03 10:03 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Shawn, the array problem has never worked. I was referring to Chris' comment about the "Mailbox not found!" not working properly.

The script run under RC2 yields:
Using Text: -2147352567 Exception occurred.
Using Array: -2147352567 Exception occurred.

The true issue appears to be that in VB or VBscript one can use the "Array" function to pass data to GetInfoEx but in Kixtart the arrays are passed the same way or are not contructed in a way that COM recognizes.

I really do not know where the GetInfoEx method can be used generically. I think that this code is quite easily spared down to something that can be used in reproducing the problem. It think that we could just ask Ruud to effectively transalate the working VB script found on MSDN that uses GetInfoEx. If he can not because of this issue, then the bug? is reproduced.

code:
Dim PropArray As Variant
Dim Prop As Variant
Dim DescList As Variant
Dim obj As IADs

Set obj = GetObject("LDAP://MyMachine")

' Initialize the array of properties to pass to GetInfoEx
PropArray = Array("description", "distinguishedName")

' Make the array a single variant for passing to GetInfoEx
Prop = PropArray

' Get just the description and DN properties
obj.GetInfoEx Prop, 0

DescList = obj.Get("description")

' Enumerate the descriptions
For Each Desc In DescList
' Print the descriptions
Deubg.Print (Desc)
Next

OR
code:
Dim x As IADs
Set x = GetObject("LDAP://CN=JSmith,CN=Users,DC=Fabrikam,DC=com")

'Retrieve givenName and sn from the underlying directory storage.
'Cache should have givenName and sn values.
x.GetInfoEx Array("givenName", "sn"), 0
Debug.Print x.Get("givenName") ' Property is in the cache
Debug.Print x.Get("sn") ' Property is in the cache

'If the "homePhone" property is not in the cache (in the next line),
'GetInfo will be called implicitly.
Debug.Print x.Get("homePhone")

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#85884 - 2002-06-05 10:47 AM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
This works for me:

$x = getobject( $ADSPath)
if $x
$ar = "homemdb", "sn"
$x.GetInfoEx( $ar, 0 )
? $x.get("homemdb")
endif

As does this:

$x = getobject( $ADSPath)
if $x
dim $ar[0]
$ar[0] = "homemdb"
$x.GetInfoEx( $ar, 0 )
? $x.get("homemdb")
endif

Note that the attribute is called 'homeMDB', without the '-'.

One side-effect of this issue is that I have found an issue with the handling of COM errors, and I've improved this in the final (it will produce the expected 'property not in cache' error if you reference a non-existant attribute).

Let me know if this helps.

Ruud

Top
#85885 - 2002-06-05 02:06 PM Re: GetInfoEx COM Bug? (Help with GetInfoEX)
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Thanks Ruud, but I am still some confused by your use of "homemdb" and not "home-mdb" as in http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ds2x/hh/ ds2x/exds_ds2exchgd_2j3s.asp

Is this a different attribute? I use the "Home-MDB" attribute in Perl and it is documented in the URL above. [Confused]

code:
Dim objMailbox As IADs
Dim objStore As IADs

Set objMailbox = _
GetObject("LDAP://Server/cn=Mailbox,cn=Recipients,ou=Site,o=Org")

objMailbox.GetInfoEx Array("Home-MDB"), 0
Debug.Print objMailbox.Get("Home-MDB")

'This distinguished name can be parsed out to obtain the server name.
' Or you can bind to the Home-MDB Path and get the parent object
StorePath = objMailbox.Get("Home-MDB")
Set objStore = GetObject("LDAP://Server/" & StorePath)
Debug.Print objStore.Parent

Set objMailbox = Nothing
Set objStore = Nothing



[ 05 June 2002, 14:09: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 565 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.164 seconds in which 0.08 seconds were spent on a total of 13 queries. Zlib compression enabled.

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