Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


MsgBox and Authentication Problems

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,49753
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> MsgBox and Authentication Problems
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 MsgBox and Authentication Problems - 7/20/2007 1:18:11 AM   
  cswarr99

 

Posts: 2
Score: 0
Joined: 7/20/2007
Status: offline
Hello.  I'm having two problems with the script below.  First, I can't seem to add any other parameters to my Msgbox function call other than the prompt agruement.  I wanted to add a title and the critical icon, but when I add those arguements, I get the error: "Microsoft VBScript compilation error: Cannot use parentheses when calling a Sub".  Second, my authentication to Active Directory doesn't seem to be working.  If it run the script from a workstation where I'm logged in as a non-Domain Admin, I enter Domain Admin credentials in my input boxes, but when the script gets to objGroup.add(objUser.ADsPath), it gives me:  " Microsoft VBScript runtime error: Permission denied".  If I run the script while logged in as a Domain Admin, the script works, so I'm assuming the script is still using the logged on user credentials instead of the credentials that I'm collecting with the input boxes.  I want it to use the credentials from the input boxes.  Thanks for any help forthcoming!
Option Explicit'On Error Resume NextConst ADS_SECURE_AUTHENTICATION = 1
Const ADS_USE_ENCRYPTION = 2Dim objNameSpaceLDAP
Dim objRootDSE
Dim strDomain, strUserName, strPassword, strError, strOU
Dim objVar, objUser, objGroup
Dim arrUsersSet objNameSpaceLDAP=GetObject("LDAP:")
Set objRootDSE=GetObject("LDAP://RootDSE")
strDomain = objRootDSE.Get("defaultNamingContext")
strUserName = InputBox("Enter Admin Account","Account Name")
strPassword = InputBox("Enter Password","Password")
strOU = "LDAP://ou=OU1,ou=OU2," & strDomain
Set objVar = objNameSpaceLDAP.OpenDSObject("LDAP://" & strDomain,strUserName,strPassword,ADS_SECURE_AUTHENTICATION)
Set objGroup = GetObject("LDAP://CN=Group,OU=OU3,OU=OU4,DC=mydomain,DC=com")
Set arrUsers = GetObject("LDAP://ou=OU5,ou=OU6,DC=mydomain,DC=com")
arrUsers.Filter = Array("user")For Each objUser in arrUsers
   objUser.TerminalServicesProfilePath = ""
   objGroup.add(objUser.ADsPath)
   objUser.SetInfo
   If Err.Number <> 0 Then ErrChk(Err.Number)
NextSub ErrChk(strError)
If Err.Number = -2147019886 Then
 MsgBox("ERROR: At least one of the users is already in group.")
ElseIf Err.Number <> 0 Then
 MsgBox("Error: " & Err.Number)
End If 
Err.Clear
End Sub
 
 
Post #: 1
 
 RE: MsgBox and Authentication Problems - 7/20/2007 2:39:09 AM   
  dm_4ever


Posts: 2723
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
From what I've seen this alternate login information is only good to query AD, but when you try to commit a change it takes on the local credentials again.  

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to cswarr99)
 
 
Post #: 2
 
 RE: MsgBox and Authentication Problems - 7/20/2007 3:01:22 AM   
  dm_4ever


Posts: 2723
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Try this...it should allow you to right click on a .vbs and select "Run As"...if it works, the whole script should run with the credentials you provided.



      

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to cswarr99)
 
 
Post #: 3
 
 RE: MsgBox and Authentication Problems - 7/20/2007 5:21:03 AM   
  cswarr99

 

Posts: 2
Score: 0
Joined: 7/20/2007
Status: offline
Thanks for the replies.  Do I add this code into my script or is it run by itself?

(in reply to dm_4ever)
 
 
Post #: 4
 
 RE: MsgBox and Authentication Problems - 7/20/2007 7:36:49 AM   
  dm_4ever


Posts: 2723
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Run this script on its own...it will add the ability to right click on a script and choose "Run As".  

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to cswarr99)
 
 
Post #: 5
 
 RE: MsgBox and Authentication Problems - 7/23/2007 8:04:27 AM   
  CondoPC


Posts: 118
Score: 0
Joined: 7/23/2007
Status: offline
As for your msgbox problem, there are two way to handle this. In vbscript, you cannot call a method and define the parameters inside of parentheses. If you want to define additional parameters, just include them
Example:

MsgBox "ERROR: At least one of the users is already in group."

or you can also call it this way:

Call MsgBox("ERROR: At least one of the users is already in group.")

or you can call it by assigning a value

errDisplay = MsgBox("ERROR: At least one of the users is already in group.")

see the following link:
http://www.w3schools.com/vbscript/func_msgbox.asp

(in reply to cswarr99)
 
 
Post #: 6
 
 RE: MsgBox and Authentication Problems - 7/25/2007 7:06:31 AM   
  Rischip


Posts: 510
Score: 2
Joined: 3/26/2007
Status: offline
Actually a little known thing about vbscript and parameters.

Some items such as MSGBOX are actually overloaded.

When called with a return value the routine you are calling is a function.
When called without a return value the routine you are calling is a subroutine. Hence the difference in syntax rules (personally I think this is beyond stupid, but it's Microsoft)

The CALL statement claims to exist to allow you to call a subroutine using parentheses. I find it funny that it allows you to call a Function as well. Be careful using it to call Functions though, it discards return values, so it kinda defeats the purpose of a function.

_____________________________

Rischip
Author of - The Grim Linker

(in reply to CondoPC)
 
 
Post #: 7
 
 RE: MsgBox and Authentication Problems - 7/25/2007 8:06:56 AM   
  CondoPC


Posts: 118
Score: 0
Joined: 7/23/2007
Status: offline
Ah thanks for the insight. I haven't run into issues using it that way yet, but it will assist in my troubleshooting in the future.

(in reply to Rischip)
 
 
Post #: 8
 
 RE: MsgBox and Authentication Problems - 7/26/2007 7:54:10 AM   
  Rischip


Posts: 510
Score: 2
Joined: 3/26/2007
Status: offline
This is actually very enlightening about the subject of parens and functions versus subs.

http://blogs.msdn.com/ericlippert/archive/2003/09/15/52996.aspx

_____________________________

Rischip
Author of - The Grim Linker

(in reply to CondoPC)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> MsgBox and Authentication Problems Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts