Page 1 of 1 1
Topic Options
#177674 - 2007-07-10 02:02 AM AD - Use Dept. field to map printer
DaveAllen Offline
Lurker

Registered: 2007-07-10
Posts: 1
I would like to put the share name of a printer in the Department field in the users' AD account. Then I want to grab that field in my script to set the users' default printer. I'm not sure how to go about this. Any ideas?
Top
#177675 - 2007-07-10 02:12 AM Re: AD - Use Dept. field to map printer [Re: DaveAllen]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Use COM and ADSI. There are tons of VBS examples and may be even a few KiX 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
#177679 - 2007-07-10 09:21 AM Re: AD - Use Dept. field to map printer [Re: DaveAllen]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
An example.

 Code:
Break on

$aAttributes = "Name","Department"
$sADsPath = "LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext")  
$strFilter = "(&(objectCategory=person)(objectClass=user)(displayName=" + @FULLNAME + "))"

$aResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter,"Name")  

For $r = 0 to Ubound($aResults)
	;$aResults[$r,0] = Fullname
	;$aResults[$r,1] = Department
	?"User: " $aResults[$r,0]
	?"Has printer: " $aResults[$r,1] " in the department field in AD."
	Sleep 5	
Next


You need to include the fnLDAPQuery() - Uses ADO to query Active Directory using LDAP dialect UDF in this code or you could call it instead of including it.
See: KiXtart FAQ & How to's » How to use UDFs if you are wondering how to do that.


Edited by Mart (2007-07-10 09:22 AM)
_________________________
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
0 registered and 1539 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.056 seconds in which 0.027 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