|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
help with logon vbs scriptopens up I get two error: access denied messages. Now the script completely works for the groups posted and attaches the drives and printers correctly... where am I getting these errors from? Can I suppress them? Does it have to do with permissions... the users on the network only are Domain Admins and the respective security group. Option Explicit 'Declare variables Dim objNetwork, objUser, CurrentUser Dim strGroup ' Initialize Groups with Const Const Accounting_Group = "cn=Accounting" Const Private_Group = "cn=SM_Private" Const Public_Group = "cn=SM_Public" Const Technology_Group = "cn=SM_Technology" Const Corporate_Group = "cn=SM_Corporate" ' Create objects and extract strGroup values Set objNetwork = CreateObject("WScript.Network") Set objUser = CreateObject("ADSystemInfo") Set CurrentUser = GetObject("LDAP://" & objUser.UserName) objNetwork.MapNetworkDrive "Q:", "\\server\Data" objNetwork.MapNetworkDrive "I:", "\\server\Common" strGroup = LCase(Join(CurrentUser.MemberOf)) ' If logic testing strGroup for the values in Const groups If InStr(strGroup, lcase(Corporate_Group)) Then objNetwork.MapNetworkDrive "J:", "\\server\Corporate" objNetwork.AddWindowsPrinterConnection "\\server\Executive-Suite" objNetwork.SetDefaultPrinter "\\server\Executive-Suite" ElseIf InStr(strGroup, lcase(Accounting_Group)) Then objNetwork.MapNetworkDrive "K:", "\\server\Accounting" objNetwork.AddWindowsPrinterConnection "\\server\Dell1815dn02" objNetwork.AddWindowsPrinterConnection "\\server\XeroxWC7345" objNetwork.SetDefaultPrinter "\\server\Dell1815dn02" ElseIf InStr(strGroup, lcase(Public_Group)) Then objNetwork.MapNetworkDrive "M:", "\\server\Public_Equity_Market" objNetwork.AddWindowsPrinterConnection "\\server\1815dn" objNetwork.AddWindowsPrinterConnection "\\server\XeroxWC4150" objNetwork.SetDefaultPrinter "\\server\1815dn(trade)" ElseIf InStr(strGroup, lcase(Private_Group)) Then objNetwork.MapNetworkDrive "N:", "\\server\Private_Company_Market" objNetwork.AddWindowsPrinterConnection "\\server\1815dn(trade)" objNetwork.AddWindowsPrinterConnection "\\server\1815dn(trade)" objNetwork.SetDefaultPrinter "\\server\1815dn(trade)" ElseIf InStr(strGroup, lcase(Technology_Group)) Then objNetwork.MapNetworkDrive "T:", "\\server\Tech" objNetwork.AddWindowsPrinterConnection "\\server\Technology" objNetwork.AddWindowsPrinterConnection "\\server\Dell3110" objNetwork.SetDefaultPrinter "\\server\Technology" End If WScript.Quit <theunlik***@gmail.com> wrote in message
Show quoteHide quote news:8a7efd03-446c-43f9-bcce-29e76767af4f@v38g2000yqb.googlegroups.com... Yes, this error message is related to permissions. You need to perform a >I have the script below which works fine.. however when the DOS prompt > opens up I get two error: access denied messages. Now the script > completely works for the groups posted and attaches the drives and > printers correctly... where am I getting these errors from? Can I > suppress them? Does it have to do with permissions... the users on the > network only are Domain Admins and the respective security group. > > Option Explicit > 'Declare variables > Dim objNetwork, objUser, CurrentUser > Dim strGroup > > ' Initialize Groups with Const > Const Accounting_Group = "cn=Accounting" > Const Private_Group = "cn=SM_Private" > Const Public_Group = "cn=SM_Public" > Const Technology_Group = "cn=SM_Technology" > Const Corporate_Group = "cn=SM_Corporate" > > ' Create objects and extract strGroup values > Set objNetwork = CreateObject("WScript.Network") > Set objUser = CreateObject("ADSystemInfo") > Set CurrentUser = GetObject("LDAP://" & objUser.UserName) > > objNetwork.MapNetworkDrive "Q:", "\\server\Data" > objNetwork.MapNetworkDrive "I:", "\\server\Common" > > strGroup = LCase(Join(CurrentUser.MemberOf)) > ' If logic testing strGroup for the values in Const groups > If InStr(strGroup, lcase(Corporate_Group)) Then > objNetwork.MapNetworkDrive "J:", "\\server\Corporate" > objNetwork.AddWindowsPrinterConnection "\\server\Executive-Suite" > objNetwork.SetDefaultPrinter "\\server\Executive-Suite" > > ElseIf InStr(strGroup, lcase(Accounting_Group)) Then > objNetwork.MapNetworkDrive "K:", "\\server\Accounting" > objNetwork.AddWindowsPrinterConnection "\\server\Dell1815dn02" > objNetwork.AddWindowsPrinterConnection "\\server\XeroxWC7345" > objNetwork.SetDefaultPrinter "\\server\Dell1815dn02" > > ElseIf InStr(strGroup, lcase(Public_Group)) Then > objNetwork.MapNetworkDrive "M:", "\\server\Public_Equity_Market" > objNetwork.AddWindowsPrinterConnection "\\server\1815dn" > objNetwork.AddWindowsPrinterConnection "\\server\XeroxWC4150" > objNetwork.SetDefaultPrinter "\\server\1815dn(trade)" > > ElseIf InStr(strGroup, lcase(Private_Group)) Then > objNetwork.MapNetworkDrive "N:", "\\server\Private_Company_Market" > objNetwork.AddWindowsPrinterConnection "\\server\1815dn(trade)" > objNetwork.AddWindowsPrinterConnection "\\server\1815dn(trade)" > objNetwork.SetDefaultPrinter "\\server\1815dn(trade)" > > ElseIf InStr(strGroup, lcase(Technology_Group)) Then > objNetwork.MapNetworkDrive "T:", "\\server\Tech" > objNetwork.AddWindowsPrinterConnection "\\server\Technology" > objNetwork.AddWindowsPrinterConnection "\\server\Dell3110" > objNetwork.SetDefaultPrinter "\\server\Technology" > > > End If > > WScript.Quit little bit of trouble shooting to find out where the problem lies. You could do it like so: Option Explicit 'Declare variables Dim objNetwork, objUser, CurrentUser Dim strGroup ' Initialize Groups with Const Const Accounting_Group = "cn=Accounting" Const Private_Group = "cn=SM_Private" Const Public_Group = "cn=SM_Public" Const Technology_Group = "cn=SM_Technology" Const Corporate_Group = "cn=SM_Corporate" ' Create objects and extract strGroup values Set objNetwork = CreateObject("WScript.Network") Set objUser = CreateObject("ADSystemInfo") Set CurrentUser = GetObject("LDAP://" & objUser.UserName) wscript.echo "Label 1" objNetwork.MapNetworkDrive "Q:", "\\server\Data" objNetwork.MapNetworkDrive "I:", "\\server\Common" wscript.echo "Label 2" strGroup = LCase(Join(CurrentUser.MemberOf)) ' If logic testing strGroup for the values in Const groups If InStr(strGroup, lcase(Corporate_Group)) Then objNetwork.MapNetworkDrive "J:", "\\server\Corporate" objNetwork.AddWindowsPrinterConnection "\\server\Executive-Suite" objNetwork.SetDefaultPrinter "\\server\Executive-Suite" wscript.echo "Label 3" ElseIf InStr(strGroup, lcase(Accounting_Group)) Then objNetwork.MapNetworkDrive "K:", "\\server\Accounting" objNetwork.AddWindowsPrinterConnection "\\server\Dell1815dn02" objNetwork.AddWindowsPrinterConnection "\\server\XeroxWC7345" objNetwork.SetDefaultPrinter "\\server\Dell1815dn02" wscript.echo "Label 4" ElseIf InStr(strGroup, lcase(Public_Group)) Then objNetwork.MapNetworkDrive "M:", "\\server\Public_Equity_Market" objNetwork.AddWindowsPrinterConnection "\\server\1815dn" objNetwork.AddWindowsPrinterConnection "\\server\XeroxWC4150" objNetwork.SetDefaultPrinter "\\server\1815dn(trade)" wscript.echo "Label 5" ElseIf InStr(strGroup, lcase(Private_Group)) Then objNetwork.MapNetworkDrive "N:", "\\server\Private_Company_Market" objNetwork.AddWindowsPrinterConnection "\\server\1815dn(trade)" objNetwork.AddWindowsPrinterConnection "\\server\1815dn(trade)" objNetwork.SetDefaultPrinter "\\server\1815dn(trade)" wscript.echo "Label 6" ElseIf InStr(strGroup, lcase(Technology_Group)) Then objNetwork.MapNetworkDrive "T:", "\\server\Tech" objNetwork.AddWindowsPrinterConnection "\\server\Technology" objNetwork.AddWindowsPrinterConnection "\\server\Dell3110" objNetwork.SetDefaultPrinter "\\server\Technology" end if msgbox "End of script"
Show quote
Hide quote
"Pegasus [MVP]" <n***@microsoft.com> wrote in message I would also point out that the following statement will raise an error if news:OWHqKazoJHA.3840@TK2MSFTNGP03.phx.gbl... > > <theunlik***@gmail.com> wrote in message > news:8a7efd03-446c-43f9-bcce-29e76767af4f@v38g2000yqb.googlegroups.com... >>I have the script below which works fine.. however when the DOS prompt >> opens up I get two error: access denied messages. Now the script >> completely works for the groups posted and attaches the drives and >> printers correctly... where am I getting these errors from? Can I >> suppress them? Does it have to do with permissions... the users on the >> network only are Domain Admins and the respective security group. >> >> Option Explicit >> 'Declare variables >> Dim objNetwork, objUser, CurrentUser >> Dim strGroup >> >> ' Initialize Groups with Const >> Const Accounting_Group = "cn=Accounting" >> Const Private_Group = "cn=SM_Private" >> Const Public_Group = "cn=SM_Public" >> Const Technology_Group = "cn=SM_Technology" >> Const Corporate_Group = "cn=SM_Corporate" >> >> ' Create objects and extract strGroup values >> Set objNetwork = CreateObject("WScript.Network") >> Set objUser = CreateObject("ADSystemInfo") >> Set CurrentUser = GetObject("LDAP://" & objUser.UserName) >> >> objNetwork.MapNetworkDrive "Q:", "\\server\Data" >> objNetwork.MapNetworkDrive "I:", "\\server\Common" >> >> strGroup = LCase(Join(CurrentUser.MemberOf)) >> ' If logic testing strGroup for the values in Const groups >> If InStr(strGroup, lcase(Corporate_Group)) Then >> objNetwork.MapNetworkDrive "J:", "\\server\Corporate" >> objNetwork.AddWindowsPrinterConnection "\\server\Executive-Suite" >> objNetwork.SetDefaultPrinter "\\server\Executive-Suite" >> >> ElseIf InStr(strGroup, lcase(Accounting_Group)) Then >> objNetwork.MapNetworkDrive "K:", "\\server\Accounting" >> objNetwork.AddWindowsPrinterConnection "\\server\Dell1815dn02" >> objNetwork.AddWindowsPrinterConnection "\\server\XeroxWC7345" >> objNetwork.SetDefaultPrinter "\\server\Dell1815dn02" >> >> ElseIf InStr(strGroup, lcase(Public_Group)) Then >> objNetwork.MapNetworkDrive "M:", "\\server\Public_Equity_Market" >> objNetwork.AddWindowsPrinterConnection "\\server\1815dn" >> objNetwork.AddWindowsPrinterConnection "\\server\XeroxWC4150" >> objNetwork.SetDefaultPrinter "\\server\1815dn(trade)" >> >> ElseIf InStr(strGroup, lcase(Private_Group)) Then >> objNetwork.MapNetworkDrive "N:", "\\server\Private_Company_Market" >> objNetwork.AddWindowsPrinterConnection "\\server\1815dn(trade)" >> objNetwork.AddWindowsPrinterConnection "\\server\1815dn(trade)" >> objNetwork.SetDefaultPrinter "\\server\1815dn(trade)" >> >> ElseIf InStr(strGroup, lcase(Technology_Group)) Then >> objNetwork.MapNetworkDrive "T:", "\\server\Tech" >> objNetwork.AddWindowsPrinterConnection "\\server\Technology" >> objNetwork.AddWindowsPrinterConnection "\\server\Dell3110" >> objNetwork.SetDefaultPrinter "\\server\Technology" >> >> >> End If >> >> WScript.Quit > > Yes, this error message is related to permissions. You need to perform a > little bit of trouble shooting to find out where the problem lies. You > could do it like so: > > Option Explicit > 'Declare variables > Dim objNetwork, objUser, CurrentUser > Dim strGroup > > ' Initialize Groups with Const > Const Accounting_Group = "cn=Accounting" > Const Private_Group = "cn=SM_Private" > Const Public_Group = "cn=SM_Public" > Const Technology_Group = "cn=SM_Technology" > Const Corporate_Group = "cn=SM_Corporate" > > ' Create objects and extract strGroup values > Set objNetwork = CreateObject("WScript.Network") > Set objUser = CreateObject("ADSystemInfo") > Set CurrentUser = GetObject("LDAP://" & objUser.UserName) > > wscript.echo "Label 1" > objNetwork.MapNetworkDrive "Q:", "\\server\Data" > objNetwork.MapNetworkDrive "I:", "\\server\Common" > > wscript.echo "Label 2" > strGroup = LCase(Join(CurrentUser.MemberOf)) > ' If logic testing strGroup for the values in Const groups > If InStr(strGroup, lcase(Corporate_Group)) Then > objNetwork.MapNetworkDrive "J:", "\\server\Corporate" > objNetwork.AddWindowsPrinterConnection "\\server\Executive-Suite" > objNetwork.SetDefaultPrinter "\\server\Executive-Suite" > > wscript.echo "Label 3" > ElseIf InStr(strGroup, lcase(Accounting_Group)) Then > objNetwork.MapNetworkDrive "K:", "\\server\Accounting" > objNetwork.AddWindowsPrinterConnection "\\server\Dell1815dn02" > objNetwork.AddWindowsPrinterConnection "\\server\XeroxWC7345" > objNetwork.SetDefaultPrinter "\\server\Dell1815dn02" > > wscript.echo "Label 4" > ElseIf InStr(strGroup, lcase(Public_Group)) Then > objNetwork.MapNetworkDrive "M:", "\\server\Public_Equity_Market" > objNetwork.AddWindowsPrinterConnection "\\server\1815dn" > objNetwork.AddWindowsPrinterConnection "\\server\XeroxWC4150" > objNetwork.SetDefaultPrinter "\\server\1815dn(trade)" > > wscript.echo "Label 5" > ElseIf InStr(strGroup, lcase(Private_Group)) Then > objNetwork.MapNetworkDrive "N:", "\\server\Private_Company_Market" > objNetwork.AddWindowsPrinterConnection "\\server\1815dn(trade)" > objNetwork.AddWindowsPrinterConnection "\\server\1815dn(trade)" > objNetwork.SetDefaultPrinter "\\server\1815dn(trade)" > > wscript.echo "Label 6" > ElseIf InStr(strGroup, lcase(Technology_Group)) Then > objNetwork.MapNetworkDrive "T:", "\\server\Tech" > objNetwork.AddWindowsPrinterConnection "\\server\Technology" > objNetwork.AddWindowsPrinterConnection "\\server\Dell3110" > objNetwork.SetDefaultPrinter "\\server\Technology" > end if > > msgbox "End of script" > the user is not a member of at least two groups(not counting the "primary" group): strGroup = LCase(Join(CurrentUser.MemberOf)) The Join method expects an array, so a type mismatch error results if CurrentUser.memberOf has no DN's or one DN. A fix would be: ====== Dim arrGroups On Error Resume Next arrGroups = objCurrentUser.GetEx("memberOf") If (Err.Number <> 0) Then On Error GoTo 0 strGroup = "" Else On Error GoTo 0 strGroup = LCase(Join(arrGroups)) End If ====== The GetEx method only raises an error if memberOf has no DN's, and it returns an array even if there is only one DN (unlike CurrentUser.memberOf which returns a "String" if there is one DN). Remember, if you see that a user is a member of two groups in ADUC, memberOf will have only one DN because one of the groups is the "primary" (generally Domain Users) and is never included in memberOf. How to use Logon Script and best freeware? Which is a good freeware if
any or any of them for a logon script and how do they work? Because i
have found a few but they create them but they dont work one i click it
and save it as a .vbs file. Also, How do I get it so that I can copy the
script into where it says Logon Script under profiles? Anybody knows?
Please Help
--
kayanat
------------------------------------------------------------------------
kayanat's Profile: http://forums.techarena.in/members/kayanat.htm
View this thread: http://forums.techarena.in/server-scripting/1139356.htmhttp://forums.techarena.in
"kayanat" <kayanat.3p8ofa@DoNotSpam.com> wrote in message Some of your questions may be answered here:news:kayanat.3p8ofa@DoNotSpam.com... > > How to use Logon Script and best freeware? Which is a good freeware if > any or any of them for a logon script and how do they work? Because i > have found a few but they create them but they dont work one i click it > and save it as a .vbs file. Also, How do I get it so that I can copy the > script into where it says Logon Script under profiles? Anybody knows? > Please Help > http://www.rlmueller.net/LogonScriptFAQ.htm
Access protected folders using system account
If syntax for numeric values SBS 2003 VB Scripting - Help Needed! Script to set share permissions on home directories Change Password LDAP query fails... because of parentheses? Undefined variable in login script Script for Thunderbird configuration !Around Variable Name! Script to find the presence of a software |
|||||||||||||||||||||||