Page 1 of 1 1
Topic Options
#189092 - 2008-08-12 09:31 PM Error using fnLDAPQuery
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
I'm trying the following code to determine when a user last changed their password:
 Code:
; LDAPQuery(WHAT, [FROM], [FILTER], [ORDER BY], [SCOPE], [USER], [PASSWORD]) 
$aData = fnLDAPQuery('pwdLastSet', 'LDAP://CN=TestUser,CN=Users,DC=corporate,DC=libgo', '(objectClass=User)')
@SERROR ?
UBound($aData) ' elements' ?
For Each $ in $aData
 $ ?
Next

I am specifying a valid user name in "Last\, First" format. If my "WHAT" is "Name", it works, but if I try the "pwdLastSet", I get an IDispatch Pointer error. According to MSDN, it's supposed to return a large int, holding the number of ms since 1/1/1601. I can't figure out why I'm getting the IDispatch Pointer error - anyone have any ideas?

Thanks,

Glenn

PS - this is Christopher Shilt's "fnLDAPQuery"
_________________________
Actually I am a Rocket Scientist! \:D

Top
#189094 - 2008-08-12 10:38 PM Re: Error using fnLDAPQuery [Re: Glenn Barnas]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11627
Loc: CA
I think it's because that is a 64bit length data value and you're not using the correct method to return that.

I think Chris or Allen did some UDF or Script for that already. Not sure of the name or post though.

Just my guess without research

Top
#189096 - 2008-08-13 12:43 AM Re: Error using fnLDAPQuery [Re: NTDOC]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Wasn't me... \:\/
Top
#189097 - 2008-08-13 07:11 AM Re: Error using fnLDAPQuery [Re: Glenn Barnas]
Kdyer Offline
KiX Supporter
*****

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

I think you might gain some clarity here:

http://www.tek-tips.com/viewthread.cfm?qid=913108&page=9

I think what you are looking for is: objUser.PasswordLastChanged

HTH,

Kent


Edited by Kdyer (2008-08-13 07:12 AM)
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#189099 - 2008-08-13 01:24 PM Re: Error using fnLDAPQuery [Re: Kdyer]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Thanks, Kent, but no..

My example was changed to protect the guilty. In my query string, I actually used "CN=User\, Test" and not "CN=TestUser". I know I'm using the correct DN because I can return other values properly - it's only the pwdLastSet that's failing. It's an 8-byte Large Int, so that may be throwing Kix off.

It's not critical, as I'm simply trying to verify some LDAP values I'm using in Tripwire rules. The rule ran overnight, so the long int isn't affecting Tripwire.

The real question now is - how to let Kix interpret the Long Int?

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#189101 - 2008-08-13 03:12 PM Re: Error using fnLDAPQuery [Re: Allen]
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 311
Loc: STRASBOURG, France
The problem is that vartype for pwdLastSet is "object". This is why you have iDispatch error.
I have made some changes in your code to test :
 Code:
break on
 
$aData = GetLastPwdSetList(
	"LDAP://CN=TestUsers,CN=Users,DC=xxx,DC=xxx",	; from where
	"&(objectClass=User)"				; filter
)
@SERROR ?
(UBound($aData,1)+1) ' elements' ?
for $i=0 to UBound( $aData,1 )
    $objUser = GetObject( "LDAP://"+$aData[$i,0] )
    $objUser.GetInfo()

    $objUser.distinguishedname+chr(9)+
    $objUser.displayname+chr(9)+
    $objUser.PasswordLastChanged ?
Next
 
Function GetLastPwdSetList($sFrom, $sFilter)
	Dim $sWhat, $sScope, $Request
 
	$sWhat = "distinguishedname"
	$sScope = "SubTree"
	$Request = fnLDAPQuery($sWhat, $sFrom, "("+$sFilter+")", , $sScope)
	if @error	exit @error	endif
 
	$GetLastPwdSetList=$Request
	Exit 0
EndFunction

In the function, i request for distinguishedName property (not pwdLastSet).
Then, with the distinguishedName, i create an object and i read properties.
Finally, i display distinguishedname, displayname and pwdLastSet.

I think this is what you tried to do.
_________________________
Christophe

Top
#189107 - 2008-08-14 04:06 AM Re: Error using fnLDAPQuery [Re: ChristopheM]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11627
Loc: CA
Here is the Integer8 I was thinking of and Chris S. made a UDF for it.
fnInteger8Date() - Returns the DATETIME of an Integer8 date object
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=145863#Post145863


Other Links of possible interest for this post

http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=133704#Post133704

http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=186460#Post186460

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 405 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.06 seconds in which 0.029 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