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