Page 1 of 1 1
Topic Options
#31144 - 2002-10-21 07:16 PM Reading Active Directory Attribute
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
We're running a kix logon script in a native mode AD environment. I would like to add a section that will read information about a user, and act on it with some printer mappings. The attribute in question is one we created called companyLocation. I can read it no problem from VBScript, but can kix use it? Thanks!!
Top
#31145 - 2002-10-21 07:25 PM Re: Reading Active Directory Attribute
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Short answer, yes. Post your snippet of VB code and we'll show you how to convert to Kixscript.
Top
#31146 - 2002-10-21 08:15 PM Re: Reading Active Directory Attribute
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
OK, here's something similar to what I want to do:

After user object is defined, map a printer name where

prtDevice = "L" & UserObj.physicalDeliveryOfficeName & "PRT"

resulting in a mapping something like

\\printserver\L00001PRT (where 00001 is the physicalDeliveryOfficeName for that user)

Somewhat make sense? I was confused in the initial post...the actual attribute I want to use is above, not companyLocation.

Top
#31147 - 2002-10-21 08:23 PM Re: Reading Active Directory Attribute
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
In your script what does this yield?
code:
  $OfficeName = $UserObj.physicalDeliveryOfficeName 
? "@error @serror"
? $OfficeName

{edit} This assumes that you have already got the $UserObj by ADSI.

[ 21. October 2002, 20:25: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#31148 - 2002-10-21 08:28 PM Re: Reading Active Directory Attribute
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
Howard, that's probably the root of my issue - I don't know how to use ADSI in my kix script. Examples on that somewhere on the boards?
Top
#31149 - 2002-10-21 08:36 PM Re: Reading Active Directory Attribute
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
There are many examples of using ADSI in KiXtart. Check out the Scripts forum, COM forum, and the UDF Library for examples.

Download the ADSI documetation from Active Directory Service Interfaces Overview
Here is a little script to get you started.
code:
break on

;
; This script determines the fully qualified distinguished name
; of the current user, then directly binds to active directory
; and queries the name of it's parent container (OU) ...
;
; Requirements: KiXtart 3.63 & Windows 2000 /w Active Directory
;

; Instantiate active directory system info ...

$sysinfo = CreateObject("adsysteminfo")
if vartypename($sysinfo)='object'

; Get user's distinguished name (DN) ...
$username = $sysinfo.username

?"ADsPath = $username"

; Bind directly to user's active directory object ...
$user = GetObject("LDAP://" + $username)

if vartypename($user)='object'

; Get the path of the parent container ...
$parentpath = $user.parent

; Get the parent ...
$parent = GetObject($parentpath)

if vartypename($parent)='object'
$ou = $parent.name

?"OrganizationalUnit = $ou"
else
? "Error creating parent object: @error @serror"
endif
else
? "Error creating user object: @error @serror"
endif
else
? "Error creating adsysteminfo object: @error @serror"
endif
exit



[ 21. October 2002, 20:38: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#31150 - 2002-10-21 08:44 PM Re: Reading Active Directory Attribute
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
cool picture thingy tr6boy !
Top
#31151 - 2002-10-21 08:53 PM Re: Reading Active Directory Attribute
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
thanks Shawn. That's my other "life"
Top
#31152 - 2002-10-21 08:54 PM Re: Reading Active Directory Attribute
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
Howard, thanks for the sample script. Looks like it'll be easier than I anticipated. 'Appreciate the help, as always!
Top
#31153 - 2002-10-21 10:13 PM Re: Reading Active Directory Attribute
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
Folks, did some searching, but coming up dry. Trying to specify that the user I want to query attributes on is the *currently* logged on user (this will run in a logon script). So I think it's just the LDAP path I need help building:

$myuser = GetObject(LDAP://$username etc)
$location = $myuser.physicalDeliveryOfficeName

IOW, I wonder if I can use the Kix $username variable to dynamically build the LDAP path as a user logs in. Thanks again!

Top
#31154 - 2002-10-21 11:42 PM Re: Reading Active Directory Attribute
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You have two choices (WinNT:// or LDAP://) provider.

$UserObj = GetObject("WinNT://@Ldomain/@userID,user")

or

$UserObj = GetObject("LDAP://@Ldomain/$ADsPath")

I show you how to get $ADsPath in the script in my previous post above.

{edit} You may have to use LDAP to get extended AD attributes/properties. WinNT:// is quite limited.

[ 21. October 2002, 23:44: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#31155 - 2002-10-22 03:05 PM Re: Reading Active Directory Attribute
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
Thanks Howard...just checking one thing. Can I be sure this will work with 3.63? I tried to carve down just enough to display the user's Location. But this code...

; *********************
$sysinfo = CreateObject("adsysteminfo")

; Get user's distinguished name (DN) ...
$username = $sysinfo.username

?"ADsPath = $username"

$UserObj = GetObject("LDAP://@Ldomain/$ADsPath")
$Location = $UserObj.PhysicalDeliveryOfficeName
? $Location

;***********************************

Returns this:

adsysteminfo
ADsPath = 0LDAP://CINTAS/$AdsPath
0

Thanks!

Top
#31156 - 2002-10-22 03:24 PM Re: Reading Active Directory Attribute
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
tr6boy,

This syntax will not work with 3.63, you need to be running at least 4.02 for the new and improved COM support. Version 3.63 of Kixtart does have OLE support, albeit very crude support. Can get it going if need be.

Top
#31157 - 2002-10-22 03:44 PM Re: Reading Active Directory Attribute
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
OK, I've been looking for an excuse to upgrade anyway. I'll take a look at that first. Thanks guys!!
Top
#31158 - 2002-10-22 04:40 PM Re: Reading Active Directory Attribute
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
I'm a very happy TR6 Boy! Thanks guys, 4.11 works like a champ.
Top
#31159 - 2002-10-22 04:48 PM Re: Reading Active Directory Attribute
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
tr6boy, to be totally honest, I would use 4.12b2 over 4.11 ... 4.11 has some "issues" to do with COM ... not necessarily anything that will effect ADSI (more to do with Access automation in our experience) ... but the COM in 4.12 is much improved over 4.11 - it has some COM bugs fixes and the performance should be a little better as well. All things being equal, if your going to upgrade anyways, i would go with the latest - even though it is a beta.

I believe that NTDOC and some other members have already rolled out 4.12 beta into production and have not expêrienced any problems. Anyone ?

[ 22. October 2002, 16:49: Message edited by: Shawn ]

Top
#31160 - 2002-10-24 03:00 PM Re: Reading Active Directory Attribute
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
Thanks for the suggestion Shawn. I can certainly work with it on my own for a while, and send it out to the clients later. I appreciate the heads-up!
Top
Page 1 of 1 1


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

Who's Online
0 registered and 699 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.035 seconds in which 0.012 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