Login | |
|
 |
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
|
|
| |
|
|
|
 |
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
|
|
| |
|
|
|
 |
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
|
|
| |
|
|
|
 |
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
|
|
| |
|
|
|
 |
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.
|
|
| |
|
|
|
|
|