Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


what is wrong with my push script??

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> what is wrong with my push script??
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 what is wrong with my push script?? - 2/24/2005 6:46:43 PM   
  kracksmith

 

Posts: 198
Score: 0
Joined: 2/24/2005
From:
Status: offline
Ok i'm a newbie in script writing. I finally got it to work but

it only works if the user in the domain has administrator rights. why? The network share folder has domain users with full rights.

Is there something to do with "strGroup = LCase(Join(currentUser.MemberOf))"? i say this is because it errors on that line with domain users. domain users with admin in the AD goes through



Option Explicit
Dim objNetwork, objUser, CurrentUser
Dim strGroup
Dim FSO

Const database1_group = "cn=database1"
Const database2_group = "cn=database2"

Set objNetwork = CreateObject("WScript.Network")
Set FSO = CreateObject("Scripting.FileSystemObject")

Set objUser = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & objUser.UserName)
strGroup = LCase(Join(currentUser.MemberOf))

If InStr(strGroup, database1_group) Then
WScript.Echo "The pushes for Group 1 works!!!"
FSO.CopyFile "\\blasms\I_folder\test\database1.txt", "C:\designDB\"
end if

If InStr(strGroup, database2_group) Then
WScript.Echo "The pushes for Group 2 works!!!"
FSO.CopyFile "\\blasms\I_folder\test\database2.txt", "C:\contrDB\"
end if
 
 
Post #: 1
 
 Re: what is wrong with my push script?? - 2/25/2005 9:16:50 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
May I ask where do you get "strGroup = LCase(Join(currentUser.MemberOf))" from ? In the last week or so, I've seen more than enough users use exactly the same code as you're using and I'm wondering why it is such a popular method of retrieving group memberships, perhaps from a web site ?

I don't believe that it is the cause in your case, but it could as well be. If the user also belongs to a group called database12, it will be matched as well.

Could you post the exact error message and line # ?

(in reply to kracksmith)
 
 
Post #: 2
 
 Re: what is wrong with my push script?? - 2/25/2005 9:34:46 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Make sure that the permissions and the share permissons are set correctly. Alot of people forget about the share permissions.

(in reply to kracksmith)
 
 
Post #: 3
 
 Re: what is wrong with my push script?? - 2/25/2005 10:59:00 AM   
  kracksmith

 

Posts: 198
Score: 0
Joined: 2/24/2005
From:
Status: offline
ok thanks for the replies. I really need to get this going.


I double and tripled check the shared drives. it says Everyone. then I added domain user and group database 1 and 2. so now i have 3 groups in the share folder.


I forgot where I got the sample script from, but it was a popular site. I think it's Guy scripting or something to those words.

Yes this script i have is killing me. It works if I give the domain users admin group in the AD. and this script errors out with this ( i can't seem to copy the picture here )

line 14 (which is that line i mention)
char 1
error type mismatch: 'join'
code 800A000D <-- i looked his up, it just says i mis typed something which I didn't.
Source: microsoft vbscript runtime error


or is there another way of writting the exact same script. I already tried if member. but was off even more.


Thanks

(in reply to kracksmith)
 
 
Post #: 4
 
 Re: what is wrong with my push script?? - 2/25/2005 11:09:16 AM   
  Bushmen

 

Posts: 122
Score: 0
Joined: 2/4/2005
From:
Status: offline
Scripting guy.. thats the microsoft scripting website, where people ask questions and they microsoft answer you back..

pretty good with good examples.

Bushmen

(in reply to kracksmith)
 
 
Post #: 5
 
 Re: what is wrong with my push script?? - 2/25/2005 3:14:14 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Damn, I can't believe they did that!

kracksmith, could you add this just before the JOIN..line and tell us the result ?
wscript.echo typename(currentUser.MemberOf)

(in reply to kracksmith)
 
 
Post #: 6
 
 Re: what is wrong with my push script?? - 2/25/2005 3:27:06 PM   
  kracksmith

 

Posts: 198
Score: 0
Joined: 2/24/2005
From:
Status: offline
thanks Token, i would need to add this in Monday and post the result because the AD is at work. i don't have a AD at home, i wish though.

so what is the difference between your script and the original script i have?

wait, you can't believe they did what?

guy scripting is not microsoft. it's some dudes web site. i'll see if i can find the site again.

(in reply to kracksmith)
 
 
Post #: 7
 
 Re: what is wrong with my push script?? - 2/25/2005 4:19:27 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
I tried the script and it worked fine. I'm just curious what went wrong on your side.

The line I ask you to add will print the type of variable that currentUser.MemberOf returns. The join function is to concatenate an array of strings into space delimited strings. It takes an array as input and 'converts' it to a string. If the input isn't an array, you will most likely to get an error like that.

I can't believe the Scripting Guys from MS actually post that method (using JOIN) to determine a user's group membership.

(in reply to kracksmith)
 
 
Post #: 8
 
 Re: what is wrong with my push script?? - 2/25/2005 5:13:41 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
I think I know what went wrong. The JOIN function failed to work because the memberof method returns NULL; therefore, it failed trying to concatenate the array into strings. The reason it is null is because by default, there is no other groups than the primary group that a user belongs to. Also note that if there is only one additional group to which the user belongs, it will return a STRING instead of ARRAY; hence, the JOIN function would FAIL AGAIN. Nonetheless, the following code should work without any problems.

The isMemeberOf function is the solution that I wrote weeks ago for solving others problems similar to yours; sadly most people still choose to use the JOIN method. For the most part JOIN works and I have no clue why it didn't in this scenario. I'll have to do some digging. The way this function works is that it will test wheher the user that executes the script belongs to a specific group; as you can see in the code below.

============================================================================
Option Explicit
Dim network, fso
Set network = CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
Const database1_group = "database1"
Const database2_group = "database2"

If isMemberOf(database1_group) Then
WScript.Echo "The pushes for Group 1 works!!!"
fso.CopyFile "\\blasms\I_folder\test\database1.txt", "C:\designDB\"
end if

If isMemberOf(database2_group) Then
WScript.Echo "The pushes for Group 2 works!!!"
fso.CopyFile "\\blasms\I_folder\test\database2.txt", "C:\contrDB\"
end If

Function isMemberOf(ByVal group)
Dim user, found, temp
found = False
Set user = GetObject("WinNT://" & CreateObject("WScript.Network").UserDomain & "/" & CreateObject("WScript.Network").UserName & ",user")
For Each temp In user.Groups
If UCase(temp.Name) = UCase(group) Then
found = True
Exit For
End If
Next
isMemberOf = found
End Function

(in reply to kracksmith)
 
 
Post #: 9
 
 Re: what is wrong with my push script?? - 2/25/2005 5:16:42 PM   
  kracksmith

 

Posts: 198
Score: 0
Joined: 2/24/2005
From:
Status: offline
hi Token, so you tried the script and it worked fine, hmmm which script did you try? was it with the new line you added or my original script?

I can't try your new line you recommend until Monday. i don't have a AD at home.

i'm sorry, guy scripting wasn't from Microsoft. but for sure I'll try that new line you recommend from above.

Just curious, what method of scripting would you use for my situation? I read somewhere I should be using ifmember.exe. I am not familiar with that though.

but if you were to write a script would yours look something like mine?

My script is suppose to make all domain user copy a file from server to their workstation on logon (so i don't have to go to each and every computer)

(in reply to kracksmith)
 
 
Post #: 10
 
 Re: what is wrong with my push script?? - 2/25/2005 5:32:05 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
I tried your script with admin account and it worked fine, but not if I use regular user account.
Just read my previous post and you should get it working.

(in reply to kracksmith)
 
 
Post #: 11
 
 Re: what is wrong with my push script?? - 2/25/2005 5:52:13 PM   
  kracksmith

 

Posts: 198
Score: 0
Joined: 2/24/2005
From:
Status: offline
thanks for all your time Token.

ok so basically I'm just going to add in: wscript.echo typename(currentUser.MemberOf)just before the JOIN line right?

I'm just reading your last post. It says script is working with admin account and not regular domain user account.

But I need this to be working with regular user account as well.

I see you have a new script using ifmember.

(in reply to kracksmith)
 
 
Post #: 12
 
 Re: what is wrong with my push script?? - 2/25/2005 5:53:38 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Forget about the line to add, I just figured it out, and re-read my post that has the working script in it.

Your scripts work with admin account only, mine work with both.

(in reply to kracksmith)
 
 
Post #: 13
 
 Re: what is wrong with my push script?? - 2/25/2005 5:58:48 PM   
  kracksmith

 

Posts: 198
Score: 0
Joined: 2/24/2005
From:
Status: offline
ok cool. I'll just use your script with the ifmember
but since I'm using the ifmember script. do I need the ifmember.exe? If i do need the ifmember.exe i would need to run it on the AD 1st right?

(in reply to kracksmith)
 
 
Post #: 14
 
 Re: what is wrong with my push script?? - 2/25/2005 6:02:51 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
eh ? What the hell is ifmember ? You don't need to use anything else for the script to work. It works as is.

(in reply to kracksmith)
 
 
Post #: 15
 
 Re: what is wrong with my push script?? - 2/25/2005 6:05:28 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
quote:
Originally posted by kracksmith

Just curious, what method of scripting would you use for my situation? I read somewhere I should be using ifmember.exe. I am not familiar with that though.



I used the isMemberOf function that I wrote to accomplish the same thing you trying to do with the JOIN function.

Are you confused ?

(in reply to kracksmith)
 
 
Post #: 16
 
 Re: what is wrong with my push script?? - 2/25/2005 6:24:09 PM   
  kracksmith

 

Posts: 198
Score: 0
Joined: 2/24/2005
From:
Status: offline
haha, ok thanks.

hmmm, one more question.

so you got rid of the ADSystemInfo, LDAP, and JOIN command. Then you added the function.

Can you tell me what does that function do? or why it's a better route to go this way using a function instead of what I was using?

(in reply to kracksmith)
 
 
Post #: 17
 
 Re: what is wrong with my push script?? - 2/25/2005 6:30:29 PM   
  kracksmith

 

Posts: 198
Score: 0
Joined: 2/24/2005
From:
Status: offline
no not confuse anymore. I looked at it wrong. you are using the If IsMemberOf not the ifmember.exe everyone else was talking about on other forums. Looking at your script it looks more confusing to understand because of the function.
but hey, if it works it works. so I'll try it out Monday @ work.


Many Thanks!

(in reply to kracksmith)
 
 
Post #: 18
 
 Re: what is wrong with my push script?? - 2/25/2005 6:37:29 PM   
  kracksmith

 

Posts: 198
Score: 0
Joined: 2/24/2005
From:
Status: offline
Of course I'll be trying out your script 1st thing Monday but here is some info on the ifmember.exe to do the same thing I was trying to accomplish.


Get ifmember.exe from the Resource Kit. You can use that in combination with some DOS errorlevels to do the same conditional branching that you're looking to do. NOTE: This will only work for local groups and domain groups that the user is a member of within their current domain/OU. It won't check group membership in other domains, etc.


it's a standalone EXE that determines if a user is a member of a particular group. Depending upon whether they are or not a DOS errorlevel condition is set. In the CMD script you can set one action to execute if they are a member or a different action to execute if they aren't a member. Unless I completely missed the boat on what you're trying to accomplish I think that's what you're trying to do in your script.


So to put it simply you'd create a file called something like logon.cmd and place it into the netlogon share of your domain controller (assuming there isn't already a domain logon script in place) You might need to add to the existing domain logon script. BTW, if you only want this to apply to Citrix logons, you can stick the scripting into the System32\usrlogon.cmd and it won't affect regular domain users, it'll only affect people logging into that Citrix server. You will need to add it to each Citrix server in this case though. If you do it in the domain logon script, you only edit one place, but it affects all users in the domain.

Anyway a quick sample would be something like this:

\\domaincontroller\netlogon\ifmember.exe "DatabaseA"
if errorlevel 1 goto DatabaseA
goto DataBaseB
:DatabaseA
copy \\server\share\filea.txt \\client\c$\path\blah.txt
goto End
:DatabaseB
copy \\server\share\fileb.txt \\client\c$\path\blah.txt
goto End
:End

Basically if they are a member of DatabaseA, the errorlevel will be 1 and it'll go to the DatabaseA label and continue processing from there. If the user isn't a member of DatabaseA, then the errorlevel won't be 1 it'll be 0 so it'll reach the goto DatabaseB statement which will make it jump to the DatabaseB label (:DatabaseB). Also after each file copy is done you need to have it goto End otherwise the processing will continue towards the bottom of the script. So without the goto end statement file copy A would happen and then it would continue processing and copy the file for DatabaseB.

If you want to know more about this ifmember.exe utility look here: http://www.jsiinc.com/suba/tip0100/rh0100.htm

(in reply to kracksmith)
 
 
Post #: 19
 
 Re: what is wrong with my push script?? - 2/26/2005 7:15:29 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
ah.. VERY informative. Thanks.

It is better because it is exactly how our mind works. It compares a list of the groups that the user belongs to against a predefine group. But I guess it's better for you because it works with domain users that don't belong to any other additional gorups.

BTW, I forgot to change two lines form your code.

Const database1_group = "cn=database1"
Const database2_group = "cn=database2"

should be

Const database1_group = "database1"
Const database2_group = "database2"

I think it's actually simplier. To demonstrate how it works with your batch example, I'll use the example you posted (in VBS of course, instead of in batch).

if isMemberOf(DatabaseA) then
fso.copyFile "\\server\share\filea.txt", "\\client\c$\path\blah.txt"
end if

if isMemberOf(DatabaseB) then
fso.copyFile "\\server\share\fileb.txt", "\\client\c$\path\blah.txt"
end if

(in reply to kracksmith)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

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 >> what is wrong with my push script?? Page: [1] 2   next >   >>
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