Location: List Archives

Your Home Page ..

Site Articles:

Add to Google

Add to My Yahoo!

Mail List Posts:

Add to Google

Add to My Yahoo!

Friends

Friends

ScriptLogic

List Archives

This forum is an archive of all posts to our mailing list over the past few years.  The forum is set read only therefore to contribute you will need to join our list community.  See more info about this here.

List Archives

Subject: RE: [ActiveDir] [OT] Configuring something concerning printers with a script - was Configuring the Enterprise Admins group and Domain Admin group usin
Prev Next
You are not authorized to post a reply.

AuthorMessages
listmailUser is Offline

Posts:291

04/28/2008 6:05 PM  
First off that subject wasn't correct.

Second I added OT because at this point who knows if this is a vista issue
or an issue with how you are querying AD. This list, despite the attempts by
many, is an Active Directory list, not a list about how to solve any old
computer problem that people elsewhere can't figure out just because there
are smart people who hang out here (and I don't include myself in that list
BTW). The random OT stuff is, IMO, why we are starting to see less and less
of the really good people responding to posts. Especially when things aren't
marked as such.

Third, what troubleshooting have you done or is it just the fact it doesn't
seem to work consistently on Vista so you just decide to ask everyone on the
list to look at every line of code to work out what may or may not be
different.


Overall, I would recommend putting in debug statements at various points and
printing out the info returned from the various pieces and figure out where
the script is going pear shaped and then explain that in the post if you
actually need help still and it didn't become clear from the data you output
in the debug statements.


As an aside and a general AD searching tip, unless you have a single domain
forest or the groups you are checking are all universal groups I wouldn't
use a GC to check memberof for the users. And I am not sure I would do that
anyway if you are worried about primary group membership or nested group
membership because it won't work in those scenarios.

joe



--
O'Reilly Active Directory Third Edition -
http://www.joeware.net/win/ad3e.htm


-----Original Message-----
From: ActiveDir-owner@mail.activedir.org
[mailto:ActiveDir-owner@mail.activedir.org] On Behalf Of
adriaoramos@sabesp.com.br
Sent: Monday, April 28, 2008 3:27 PM
To: ActiveDir@mail.activedir.org
Cc: ActiveDir@mail.activedir.org; ActiveDir-owner@mail.activedir.org
Subject: RE: [ActiveDir] Configuring the Enterprise Admins group and Domain
Admin group using Restricted Groups

Hi all.
I have a problem running a printer script in my desktops
I tested this script in a Windows XP based machine, and it worked
fine.
But in my Vista workstations, it is failing. sometimes works, and
other no.
I would like to know if there is anything I can do to make it run, if
there is something different to run in Windows Vista.
Can you Help me?
This is my script. The user are in the correct groups in my domain


On Error Resume Next
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D Const ADS_SCOPE_SUBTREE = 2
Const ADS_UF_ACCOUNTDISABLE = 2 Const ForReading = 1, ForWriting = 2,
ForAppending = 8 DIM aLst(2) strComputer = "."
xDefault = "Padrão"
Set objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colComputer = objWMIService.ExecQuery("Select * from
Win32_ComputerSystem")
For Each objComputer in colComputer
xUser = objComputer.UserName
xUserB = Right(xUser,Len(xUser)-InStr(xUser,"\"))
Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDC = GetObject("GC://dc=sabesp,dc=com,dc=br")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False '
'-- Monta o comando SQL da consulta
'
xAdm_Gab = False
xAssessores = False
xApoio = False
xSecretarias = False
For each objsubRefs in objDC.subRefs
'
'--- Efetua a Consulta de disponibilidade do LOGON no AD --- '
objCommand.CommandText = _
"<GC://" & objsubRefs & ">;" & _
"(sAMAccountName=" & xUserB & ");" & _
"Name, cn, sAMAccountName, distinguishedName;" & _
"subtree"
Set objRecordSet = objCommand.Execute
If not objRecordSet.EOF Then
xDN = "LDAP://" & objRecordSet.Fields("distinguishedName").Value
objRecordSet.MoveFirst
Set objUserB = GetObject(xDN)
objMemberOf = objUserB.GetEx("MemberOf") '
'-- Listas os Grupos associados a um dado usuário '
For Each xGrupo in objMemberOf
If xGrupo = "CN=Administrativo_Gabinete,OU=Gabinete da
Presidencia,OU=Hold,OU=Costa,DC=spo,DC=sabesp,DC=com,DC=br" Then
xAdm_Gab = True
ElseIf xGrupo = "CN=Presidencia_Apoio,OU=Gabinete da
Presidencia,OU=Hold,OU=Costa,DC=spo,DC=sabesp,DC=com,DC=br" Then
xApoio = True
ElseIf xGrupo = "CN=Assessores da Presidência,OU=Gabinete da
Presidencia,OU=Hold,OU=Costa,DC=spo,DC=sabesp,DC=com,DC=br" Then
xAssessores = True
ElseIf xGrupo = "CN=Secretarias_Presidencia,OU=Gabinete da
Presidencia,OU=Hold,OU=Costa,DC=spo,DC=sabesp,DC=com,DC=br" Then
xSecretarias = True
End If
Next
End If
Next

If xAdm_Gab Then
' -- Lista de impressoras do Grupo "Administrativo_Gabinete" da Presidencia.
aPrinterPath = Array("\\spo-info213\PPD_M",_
"\\spo-info213\PPD_C-1",_
"\\spo-info213\PPD_C-2") aPrinterDriver = Array("RICOH
Aficio MP 2000 PCL 6",_
"HP Color LaserJet 3600",_
"HP Color LaserJet 3600") '
ElseIf xApoio Then
' -- Lista de impressoras do Grupo "Presidencia_Apoio" da Presidencia.
aPrinterPath = Array("\\spo-info213\HP_Color_P-1")
aPrinterDriver = Array("HP Color LaserJet 3600") '
ElseIf xAssessores Then
' -- Lista de impressoras do Grupo "Assessores da Presidência" da
Presidencia.
aPrinterPath = Array("\\spo-info213\AFICIO_COLOR_P",_
"\\spo-info213\HP_Color_P-2") aPrinterDriver =
Array("RICOH Aficio MP C2500 PCL 6",_
"HP Color LaserJet 3600") '
ElseIf xSecretarias Then
' -- Lista de impressoras do Grupo "Secretarias_Presidencia" da Presidencia.
aPrinterPath = Array("\\spo-info213\RICOH_Mono_PPS",_
"\\spo-info213\HP_Color_PPS") aPrinterDriver =
Array("RICOH Aficio MP 2000 PCL 6",_
"HP Color LaserJet 3600") End If '
' -- Registra qual é a impressoras padrão.
Set objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery("Select * from
Win32_Printer")
Set colOperatingSystems = objWMIService.ExecQuery("Select * from
Win32_OperatingSystem")
W2K = false
For Each objOperatingSystem in colOperatingSystems
If Instr(objOperatingSystem.Caption, "2000") > 0 Then
W2K = True
End If
Next
If W2K Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("c:\Impr_Pdr.txt") Then
Set objFile = objFSO.OpenTextFile("c:\Impr_Pdr.txt", ForReading)
xDefault = objFile.ReadLine
Else
Set objFile = objFSO.OpenTextFile("c:\Impr_Pdr.txt", ForWriting, True)
For Each xDefault in aPrinterPath
If MsgBox("É esta sua Impressora Padrão?" & vbCrLf & xDefault,
vbYesNo, "Seleção de Impressora Padrão") = vbYes Then
Exit For
End If
Next
objFile.Write xDefault
End If
objFile.Close
Else
For Each objPrinter in colInstalledPrinters
If objPrinter.Default Then
xDefault = objPrinter.Name
End If
Next
End If
'
' -- Desconecta as impressoras de rede.
Set WshNetwork = WScript.CreateObject("WScript.Network")
For Each objPrinter in colInstalledPrinters
If Instr(objPrinter.Name,"spo-info213")>0 Then
WshNetwork.RemovePrinterConnection objPrinter.Name
End If
Next
'
' -- Conecta as impressoras de rede.
Set WshNetwork = CreateObject("WScript.Network") For i = 0 To
UBound(aPrinterPath) Step 1
WshNetwork.AddWindowsPrinterConnection aPrinterPath(i), aPrinterDriver(i)
If UCase(xDefault) = UCase(aPrinterPath(i)) Then
WshNetwork.SetDefaultPrinter aPrinterPath(i)
End If
Next


List info : http://www.activedir.org/List.aspx
List FAQ : http://www.activedir.org/ListFAQ.aspx
List archive: http://www.activedir.org/ma/default.aspx

List info : http://www.activedir.org/List.aspx
List FAQ : http://www.activedir.org/ListFAQ.aspx
List archive: http://www.activedir.org/ma/default.aspx
You are not authorized to post a reply.
Forums >ActiveDir Mail List Archive >List Archives > RE: [ActiveDir] [OT] Configuring something concerning printers with a script - was Configuring the Enterprise Admins group and Domain Admin group usin



ActiveForums 3.7
AdventNet Banner
Friends

Friends

Namescape
Members

Members

MembershipMembership:
Latest New UserLatest:mccall12345
New TodayNew Today:1
New YesterdayNew Yesterday:3
User CountOverall:4177

People OnlinePeople Online:
VisitorsVisitors:167
MembersMembers:0
TotalTotal:167

Online NowOnline Now:

Ads

Copyright 2008 ActiveDir.org
Terms Of Use