Login | |
|
 |
Binding to OU in active directory - 7/19/2005 2:45:04 AM
|
|
 |
|
| |
jraisor
Posts: 39
Score: 0
Joined: 4/29/2005
From:
Status: offline
|
Howdy me again. :) Ok so i've had success with creating a script that will see what Global Group a PC belongs to and then map a printer accordingly. Well i'd like to do away with putting PC's in global groups and just have the script search what OU the computer belongs to and map that way. Here is my current part of the script that accomplishes the mapping by group. can anyone help me with going to mapping by OU? I've tried to edit current lines to somthing like Set objGroup2 = GetObject("LDAP://ou= HR PC's,ou=GI PC's,ou=GI,dc=app,dc=com") but it gives me errors saying there is no such object on the server. I really would be grateful for any input. Thanks *************************************************************************** strComputer = objNetwork.ComputerName objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & strComputer & "$" strComputerDN = objTrans.Get(ADS_NAME_TYPE_1779) ' Bind to the computer object in Active Directory with the LDAP ' provider. Set objComputer = GetObject("LDAP://" & strComputerDN) ' Bind to a group object in Active Directory with the LDAP provider. Set objGroup2 = GetObject("LDAP://cn= HR PC,ou=GI PC's,ou=GI,dc=app,dc=com") Set objGroup3 = GetObject("LDAP://cn= IT PC,ou=GI PC's,ou=GI,dc=app,dc=com") Set objGroup4 = GetObject("LDAP://cn= Eng PC,ou=GI PC's,ou=GI,dc=app,dc=com") Set objGroup5 = GetObject("LDAP://cn= Maint PC,ou=GI PC's,ou=GI,dc=app,dc=com") Set objGroup6 = GetObject("LDAP://cn=Material PC,ou=GI PC's,ou=GI,dc=app,dc=com") Set objGroup7 = GetObject("LDAP://cn= Micro PC,ou=GI PC's,ou=GI,dc=app,dc=com") Set objGroup8 = GetObject("LDAP://cn= QS PC,ou=GI PC's,ou=GI,dc=app,dc=com") Set objGroup9 = GetObject("LDAP://cn= ProdRel PC,ou=GI PC's,ou=GI,dc=app,dc=com") Set objGroup10 = GetObject("LDAP://cn= Techtran PC,ou=GI PC's,ou=GI,dc=app,dc=com") Set objGroup11 = GetObject("LDAP://cn= Val PC,ou=GI PC's,ou=GI,dc=app,dc=com") ' Add a printer connection if the computer is a member of the group. If objGroup2.IsMember(objComputer.AdsPath) Then objNetwork.AddWindowsPrinterConnection "\\sledc01\HR_C" Elseif objGroup3.IsMember(objComputer.AdsPath) Then objNetwork.AddWindowsPrinterConnection "\\sledc01\MIS_laser" *************************************************************************************
|
|
| |
|
|
|
 |
RE: Binding to OU in active directory - 7/21/2005 11:33:16 AM
|
|
 |
|
| |
marcusrp
Posts: 145
Score: 0
Joined: 4/19/2005
From:
Status: offline
|
quote:
Set objGroup2 = GetObject("LDAP://cn= HR PC,ou=GI PC's,ou=GI,dc=app,dc=com") this is just a guess, I've run into this problem with using shell objects that send command strings with spaces in them, but not like yours where its running vbscript the whole time, but try changing the above (or any of your OU paths statements) as a test to this: Set objGroup2 = GetObject(chr(34) & "LDAP://cn= HR PC,ou=GI PC's,ou=GI,dc=app,dc=com" & chr(34)) The chr(34) construct is used in place of double quotes where you enclose strings that have spaces in them. since your ou names have spaces, this might fix the problem. Or it might not! Let me know if it does or does not work...
|
|
| |
|
|
|
|
|