Page 1 of 1 1
Topic Options
#145636 - 2005-08-15 10:28 PM DS Query returns via ADSI
Zeet Offline
Fresh Scripter

Registered: 2005-08-15
Posts: 19
Hi,

I'm in the process of cleaning up our company's login script. I've decided to port the entire thing over to KIX but I'm having trouble with the ADSI elements. I've looked and I've looked and I've yet to find a really good description of ADSI and I'm quite weak on COM/ADSI.

What I'm trying to do is two fold:

1> I am trying to write a function that takes as input either a user or a computer and returns that object's location in the AD tree.

2> Once I have found the object I would like to see 20 custom exchange attributes that are properties of the users, and if possible the other properties that show up in the GUI when you look at a user or computer.

Thus far I've managed to connect to the ROOTDSE but umm, thats about it.

Could anyone guide me on how to make a UDF that functions just like the DSQUERY command and then help me reveal that object's attributes?

I was thinking:


QueryDS($objName) ;pass either a computer name or user name to a function. Return the location of that object in AD by expressing it as its Full LDAP name

CaptureProperties($ObjDNName) ;Store the user account properties by querying LDAP on the user and then passing to an array

____
Thanks for any help you may be able to offer.

Top
#145637 - 2005-08-15 10:41 PM Re: DS Query returns via ADSI
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
How about this UDF?
http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=141262&an=0&page=0#141262

There are some docs available in this topic: http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=124425&an=0&page=0#124425


Edited by Mart (2005-08-15 10:42 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#145638 - 2005-08-15 10:50 PM Re: DS Query returns via ADSI
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
There is the InContainer() UDF that will return OU membership or you can mine the OUs out of TranslateName().
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#145639 - 2005-08-15 10:58 PM Re: DS Query returns via ADSI
Zeet Offline
Fresh Scripter

Registered: 2005-08-15
Posts: 19
Thanks, I forgot to mention that I was getting time out errors last night on a couple of the pages that **may** have answered my question. If I encounter them again I will document the broken links, in the meantime I'm off to read on these links....thank you both.
Top
#145640 - 2005-08-16 12:50 AM Re: DS Query returns via ADSI
Zeet Offline
Fresh Scripter

Registered: 2005-08-15
Posts: 19
blah..no joy....if i Posted a small VB function here would some one assit me in translating?
Top
#145641 - 2005-08-16 12:52 AM Re: DS Query returns via ADSI
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Probably so if it's not too large.
Top
#145642 - 2005-08-16 01:01 AM Re: DS Query returns via ADSI
Zeet Offline
Fresh Scripter

Registered: 2005-08-15
Posts: 19
'Function: TransLDAP
'Arguments:
'Description:
'-----------------------------------------------------------------------------
Function TransLDAP(Domain,Obj)

DIM message
DIM adsNameTranslate
DIM ObjDN

CONST LOCATION = "TRANSLDAP"

ON ERROR RESUME NEXT

' writelog LOCATION, "Start " & LOCATION

' writelog LOCATION,"Translate: " obj & "@" domain

' Use NameTranslate to look up the computer in the directory
Set adsNameTranslate = CreateObject("NameTranslate")
adsNameTranslate.Init ADS_NAME_INITTYPE_GC, vbNullString

' Set the user name into nametranslate
' Specify unknown format, so that system will guess
' adsNameTranslate.Set ADS_NAME_TYPE_UNKNOWN, Domain & "\" & Obj
adsNameTranslate.Set ADS_NAME_TYPE_UNKNOWN, obj & "@" & Domain

' Get the DN of the object
ObjDN = adsNameTranslate.Get(ADS_NAME_TYPE_1779)

If ObjDN = "" then
' sendlog = true
message = "****************** ObjDN is Null for: " & obj & "@" & domain
TransLDAP = ""
writelog LOCATION, message
Else
message = "ObjDN: " & ObjDN
TransLDAP = "LDAP://" & ObjDN
End if

set adsNameTranslate = nothing

' Writelog LOCATION, "End " & LOCATION

End Function


_____________--

SO then later he can call the function like this
strAdsComputer = TransLDAP(strCompDomain,wshComputerName & "$")
and
TransLDAP(Group_Domain,group)
strAdsMember = TransLDAP(AdsMemberDomain,AdsMember.Name)

Thanks in advance.

Top
#145643 - 2005-08-16 01:40 AM Re: DS Query returns via ADSI
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Well that has already been converted and turned into a UDF.

TranslateName() - converts a name from one type to another

Between this and the other 2 links given you should easily be able to get back any type of information you're looking for.

Top
#145644 - 2005-08-16 05:08 PM Re: DS Query returns via ADSI
Zeet Offline
Fresh Scripter

Registered: 2005-08-15
Posts: 19
Thank you very much for your assistance, I've been able to tie my script into AD quite nicely with the information provided.

Could you please help me create a script to set $wife_happy="always on"
and A script that runs each morning to deposit $45,500 to my bank account?


Edited by Zeet (2005-08-16 05:09 PM)

Top
#145645 - 2005-08-16 05:17 PM Re: DS Query returns via ADSI
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Quote:

Could you please help me create a script to set $wife_happy="always on"
and A script that runs each morning to deposit $45,500 to my bank account?




We've been trying to get Ruud to add...

Code:

$=SetOption("WifeHappy","On")



...but it always returns "The parameter is incorrect."

Top
#145646 - 2005-08-16 06:34 PM Re: DS Query returns via ADSI
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
ROFLMAO
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#145647 - 2005-08-16 06:49 PM Re: DS Query returns via ADSI
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
LOL

@ERROR returns: 197
"The operating system is not presently configured to run this application."

Top
#145648 - 2005-08-17 10:22 AM Re: DS Query returns via ADSI
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I used to get regular failures with:
Code:
udfIntroduce($oGirlfriend,$oMother)
ERROR: [1306] Indicates two revision levels are incompatible.



Now that I've got that one sorted I'm struggling with:
Code:
udfAdjustSpending($oPartner,"Shoes",-0.5)
ERROR: [1820] A communications failure occurred during a remote procedure call.



And I'm always in trouble with
Code:
udfGetCalendarEntry("Anniversary")
ERROR: [998] Invalid access to memory location.


Top
#145649 - 2005-08-17 11:06 AM Re: DS Query returns via ADSI
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Even more LOL then the one Chris posted.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

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
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.064 seconds in which 0.025 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