Page 1 of 1 1
Topic Options
#148102 - 2005-09-20 09:43 PM Auto creating printers using AD groups
Duke999 Offline
Fresh Scripter

Registered: 2005-09-20
Posts: 13
Hello All,
Forgive me for being a kix numskull, I've only just started looking at it for auto creating outlook profiles(excellent) and printers etc.
I have created AD distribution lists, added users into them and want to auto create printers for the dist group.
I have tried this bit of code but can not seem to get it to work properly.
I am using the latest Kix version 4.5 and call it from a batch file kix.exe kixscript.kix

; Set Printers
If fnInGroupAD("Sharp Printer")
AddPrinterConnection ("\\servername\SHARP AR-407 PCL6") = 0
? "Added printer connection...."
EndIf
If fnIngroupAD("Cardvat 1200 Printer")
AddPrinterConnection ("\\servername\HP LaserJet 1200 Series PCL 6")
SetDefaultPrinter ("\\servername\HP LaserJet 1200 Series PCL 6")
? "Added printer connection...."
Endif
if @userid = user
SetDefaultPrinter ("\\servername\SHARP AR-407 PCL6")
Endif

Top
#148103 - 2005-09-20 09:56 PM Re: Auto creating printers using AD groups
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
KiX will NOT use distribution lists natively. Since you did not provide details on the fnIngroupAD() UDF, I cannot say if it supports distribution groups. Why not use security groups?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#148104 - 2005-09-20 10:00 PM Re: Auto creating printers using AD groups
Duke999 Offline
Fresh Scripter

Registered: 2005-09-20
Posts: 13
Thanks for the prompt reply Les,
So if I create a security group instead could I just use IF InGroup instead?, then I would not need a UDF?, what is a UDF anyway?
Thanks
Mark

Top
#148105 - 2005-09-20 10:08 PM Re: Auto creating printers using AD groups
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
If you're doing group membership lookup then no you would not need a UDF (a UDF is User Defined Function, please look in the FAQ section here on the board for further details on UDF)

If InGroup('MyDomain\MyNewGroup')
  'User Found' ?
Else
  'User not found' ?
EndIf
 
If you're basing it on machines then you will need to use a UDF for this.

Hopefully you're using KiXtart 4.23 or newer.

Top
#148106 - 2005-09-20 10:15 PM Re: Auto creating printers using AD groups
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

could I just use IF InGroup instead?



That depends... InGroup() supports User membership but not Computer memebership.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#148107 - 2005-09-20 10:19 PM Re: Auto creating printers using AD groups
Duke999 Offline
Fresh Scripter

Registered: 2005-09-20
Posts: 13
Cheers NTDOC,
I'm using the latest KIX32.exe (4.5).
All i'm trying to do is auto create printers for citrix clients running roaming profiles.
I'm just looking for a quick simple script that created the printers for the users in the group.
If I change the group for a dist to a security do I use the following?

If InGroup("domain\printergroup")
'User Found' ?
AddPrinterConnection ("\\servername\SHARP AR-407 PCL6") = 0
? "Added printer connection...."
Else
'User not found' ?
EndIf

Thanks
Mark

Top
#148108 - 2005-09-20 10:34 PM Re: Auto creating printers using AD groups
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Sounds like it would work. You don't need the 'User found' stuff as that was just an example for debug or explanation.
Top
#148109 - 2005-09-20 10:51 PM Re: Auto creating printers using AD groups
Duke999 Offline
Fresh Scripter

Registered: 2005-09-20
Posts: 13
Cheers Chaps,
You are indeed the script guru's
Will give it a go tomorrow and see.
Reward yourself with a nice cold Kronkin Bonkin (Kreonenburg 1664).
Battery going on the laptop so off to the pub.

Top
#148110 - 2005-09-21 03:31 PM Re: Auto creating printers using AD groups
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
fnInGroupAD() does indeed support Distribution groups, I just tested it, whereas InGroup() does not. I'd still suggest using Securtiy groups for this operation unless you setup the DL for the purpose of informing users of events with those printers.

What is an UDF? A user defined function. It must be included in your script if you are going to use it. There is a FAQ in the FAQ Forum describing the usage of UDF's.

Top
#148111 - 2005-09-21 04:00 PM Re: Auto creating printers using AD groups
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Chris,
How can you say that? How do you know where the fnInGroupAD() UDF referenced above came from?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#148112 - 2005-09-21 04:14 PM Re: Auto creating printers using AD groups
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I wrote it. It's in the UDF library.
Top
#148113 - 2005-09-21 04:18 PM Re: Auto creating printers using AD groups
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Chris,
I know your wrote the UDF, fnInGroupAD() that is in our library. That is not the point. The point is anyone could write a UDF and call it fnInGroupAD(). Duke999 failed to say where he got the UDF from and we cannot assume that it is the one from this site.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#148114 - 2005-09-21 04:29 PM Re: Auto creating printers using AD groups
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Ah, well you got me. I fell for the trap and assumed he got it from here.
Top
#148115 - 2005-09-21 10:00 PM Re: Auto creating printers using AD groups
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Your UDF may find membership Chris but using a Distribution List for controlling access for security is not really supported.


The Role of Groups and Access Control Lists in Exchange 2000 Server Deployment
http://www.microsoft.com/technet/prodtechnol/exchange/2000/deploy/access.mspx

http://www.slipstick.com/contacts/dl.htm

http://support.microsoft.com/?kbid=242039

Top
#148116 - 2005-09-21 11:37 PM Re: Auto creating printers using AD groups
Duke999 Offline
Fresh Scripter

Registered: 2005-09-20
Posts: 13
Chaps,
I changed the script to use InGroup and all works fine with a security group.
Thanks for the help.
I've looked at the UDF from your forum, looks far more complicated then just using the InGroup statement. what would be the advantage to using this instead?.
How would I use this to autocreate say PrinterA to AD security group ADPrint1

Function fnInGroupAD(ADPrint1)
Dim $objSys,$objTarget,$aMemberOf,$sMemberOf
$objSys = CreateObject("ADSystemInfo")
$objTarget = GetObject("LDAP://"+Iif($bComputer,$objSys.ComputerName,$objSys.UserName))
$aMemberOf = $objTarget.GetEx("memberOf")
For Each $sMemberOf in $aMemberOf
If InStr($sMemberOf,"CN="+$sGroup+",")
$fnInGroupAD = Not 0
Exit
EndIf
Next
$fnInGroupAD = NOT 1
AddPrinterConnection ("\\servername\PrinterA") = 0
EndFunction

Top
#148117 - 2005-09-22 12:16 AM Re: Auto creating printers using AD groups
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Doc, didn't I say that he should use security groups? I just made mention of the fact that fnInGroupAD() works with groups that InGroup() cannot handle (e.g. Universal Groups, Distribution Groups).

Duke, I don't think you've grasped how to use UDF's yet. There is no need to change the UDF at all, you include it in your script and then use it the same as a command or function that is native to KiX.

You should really review the FAQ: How to use UDFs

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

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