what is wrong with my push script??

Change Page: 12 > | Showing page 1 of 2, messages 1 to 20 of 39
Author Message
kracksmith

  • Total Posts : 198
  • Scores: 0
  • Reward points : 0
  • Joined: 2/24/2005
  • Location:
  • Status: offline
what is wrong with my push script?? Thursday, February 24, 2005 7:46 PM (permalink)
0
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
 
#1
    token

    • Total Posts : 1917
    • Scores: 0
    • Reward points : 0
    • Joined: 1/14/2005
    • Location:
    • Status: offline
    Re: what is wrong with my push script?? Friday, February 25, 2005 10:16 AM (permalink)
    0
    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 # ?

     
    #2
      tnoonan

      • Total Posts : 364
      • Scores: 0
      • Reward points : 0
      • Joined: 12/14/2004
      • Location:
      • Status: offline
      Re: what is wrong with my push script?? Friday, February 25, 2005 10:34 AM (permalink)
      0
      Make sure that the permissions and the share permissons are set correctly. Alot of people forget about the share permissions.
       
      #3
        kracksmith

        • Total Posts : 198
        • Scores: 0
        • Reward points : 0
        • Joined: 2/24/2005
        • Location:
        • Status: offline
        Re: what is wrong with my push script?? Friday, February 25, 2005 11:59 AM (permalink)
        0
        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


         
        #4
          Bushmen

          • Total Posts : 122
          • Scores: 0
          • Reward points : 0
          • Joined: 2/4/2005
          • Location:
          • Status: offline
          Re: what is wrong with my push script?? Friday, February 25, 2005 12:09 PM (permalink)
          0
          Scripting guy.. thats the microsoft scripting website, where people ask questions and they microsoft answer you back..

          pretty good with good examples.

          Bushmen
           
          #5
            token

            • Total Posts : 1917
            • Scores: 0
            • Reward points : 0
            • Joined: 1/14/2005
            • Location:
            • Status: offline
            Re: what is wrong with my push script?? Friday, February 25, 2005 4:14 PM (permalink)
            0
            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)

             
            #6
              kracksmith

              • Total Posts : 198
              • Scores: 0
              • Reward points : 0
              • Joined: 2/24/2005
              • Location:
              • Status: offline
              Re: what is wrong with my push script?? Friday, February 25, 2005 4:27 PM (permalink)
              0
              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.
               
              #7
                token

                • Total Posts : 1917
                • Scores: 0
                • Reward points : 0
                • Joined: 1/14/2005
                • Location:
                • Status: offline
                Re: what is wrong with my push script?? Friday, February 25, 2005 5:19 PM (permalink)
                0
                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.

                 
                #8
                  token

                  • Total Posts : 1917
                  • Scores: 0
                  • Reward points : 0
                  • Joined: 1/14/2005
                  • Location:
                  • Status: offline
                  Re: what is wrong with my push script?? Friday, February 25, 2005 6:13 PM (permalink)
                  0
                  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

                   
                  #9
                    kracksmith

                    • Total Posts : 198
                    • Scores: 0
                    • Reward points : 0
                    • Joined: 2/24/2005
                    • Location:
                    • Status: offline
                    Re: what is wrong with my push script?? Friday, February 25, 2005 6:16 PM (permalink)
                    0
                    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)
                     
                    #10
                      token

                      • Total Posts : 1917
                      • Scores: 0
                      • Reward points : 0
                      • Joined: 1/14/2005
                      • Location:
                      • Status: offline
                      Re: what is wrong with my push script?? Friday, February 25, 2005 6:32 PM (permalink)
                      0
                      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.

                       
                      #11
                        kracksmith

                        • Total Posts : 198
                        • Scores: 0
                        • Reward points : 0
                        • Joined: 2/24/2005
                        • Location:
                        • Status: offline
                        Re: what is wrong with my push script?? Friday, February 25, 2005 6:52 PM (permalink)
                        0
                        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.
                         
                        #12
                          token

                          • Total Posts : 1917
                          • Scores: 0
                          • Reward points : 0
                          • Joined: 1/14/2005
                          • Location:
                          • Status: offline
                          Re: what is wrong with my push script?? Friday, February 25, 2005 6:53 PM (permalink)
                          0
                          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.

                           
                          #13
                            kracksmith

                            • Total Posts : 198
                            • Scores: 0
                            • Reward points : 0
                            • Joined: 2/24/2005
                            • Location:
                            • Status: offline
                            Re: what is wrong with my push script?? Friday, February 25, 2005 6:58 PM (permalink)
                            0
                            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?
                             
                            #14
                              token

                              • Total Posts : 1917
                              • Scores: 0
                              • Reward points : 0
                              • Joined: 1/14/2005
                              • Location:
                              • Status: offline
                              Re: what is wrong with my push script?? Friday, February 25, 2005 7:02 PM (permalink)
                              0
                              eh ? What the hell is ifmember ? You don't need to use anything else for the script to work. It works as is.
                               
                              #15
                                token

                                • Total Posts : 1917
                                • Scores: 0
                                • Reward points : 0
                                • Joined: 1/14/2005
                                • Location:
                                • Status: offline
                                Re: what is wrong with my push script?? Friday, February 25, 2005 7:05 PM (permalink)
                                0
                                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 ?
                                 
                                #16
                                  kracksmith

                                  • Total Posts : 198
                                  • Scores: 0
                                  • Reward points : 0
                                  • Joined: 2/24/2005
                                  • Location:
                                  • Status: offline
                                  Re: what is wrong with my push script?? Friday, February 25, 2005 7:24 PM (permalink)
                                  0
                                  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?


                                   
                                  #17
                                    kracksmith

                                    • Total Posts : 198
                                    • Scores: 0
                                    • Reward points : 0
                                    • Joined: 2/24/2005
                                    • Location:
                                    • Status: offline
                                    Re: what is wrong with my push script?? Friday, February 25, 2005 7:30 PM (permalink)
                                    0
                                    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!
                                     
                                    #18
                                      kracksmith

                                      • Total Posts : 198
                                      • Scores: 0
                                      • Reward points : 0
                                      • Joined: 2/24/2005
                                      • Location:
                                      • Status: offline
                                      Re: what is wrong with my push script?? Friday, February 25, 2005 7:37 PM (permalink)
                                      0
                                      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
                                       
                                      #19
                                        token

                                        • Total Posts : 1917
                                        • Scores: 0
                                        • Reward points : 0
                                        • Joined: 1/14/2005
                                        • Location:
                                        • Status: offline
                                        Re: what is wrong with my push script?? Saturday, February 26, 2005 8:15 AM (permalink)
                                        0
                                        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

                                         
                                        #20

                                          Online Bookmarks Sharing: Share/Bookmark
                                          Change Page: 12 > | Showing page 1 of 2, messages 1 to 20 of 39

                                          Jump to:

                                          Current active users

                                          There are 0 members and 1 guests.

                                          Icon Legend and Permission

                                          • 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
                                          • Read Message
                                          • Post New Thread
                                          • Reply to message
                                          • Post New Poll
                                          • Submit Vote
                                          • Post reward post
                                          • Delete my own posts
                                          • Delete my own threads
                                          • Rate post

                                          2000-2012 ASPPlayground.NET Forum Version 3.9