Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Folder Permissions
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01246703
Message ID:
01246724
Views:
22
Make Run method wait for execution to complete
oWsh.Run(lcCommand, 0, .T.)
>I've completed an application that takes a text file and updates a client's Active Directory based on the text file. Everything works fine (new users are added to AD, changes are working correctly, such as moving a user from one OU to another, etc).
>
>However, after the fact, the client has asked that I also set the home drive and home directory for new users. No problem with setting those attributes in AD, but I'm having some issues with the permissions of each folder that is created for each new user.
>
>For example, Joe Smith gets added to AD as a new user. His CN in AD is SMITHJ... So I create a folder named SMITHJ inside the root folder that has been configured to be the root folder for all user home directories. Folder gets created properly BUT when I attempt to set the permissions for the folder SMITHJ so that only SMITHJ has write access to it, I'm encountering some odd behavior.
>
>Here's a snippet of the code:
>
>oWsh = CreateObject("WScript.Shell")
>lcCommand = [cacls "] + cFullDirName + [" /T /E /C /G ] + cTmpLoginName + [:F]
>oWsh.Run(lcCommand)
>
>
>Prior to the line of code above, I'm scanning through a table of users, creating the variable cFullDirName and setting it equal to the root folder used for AD home directories (let's call it \\Server1\StudentStorage and adding to it the user name (SMITHJ, stored in the variable cTmpLoginName) so the value of cFullDirName becomes \\Server1\StudentStorage\SMITHJ. I then use the VFP command MD to create the directory and then call the code above (which should set that user as having full rights to that folder).
>
>I'm testing with 4 records and each time ALL four folders are created properly, but randomly the folders will sometimes have that user listed in the security tab with the proper permissions, sometimes without the proper permissions, and sometimes the user is not even shown in the security tab at all. It's not always the same user and it doesn't happen all the time.
>
>My first thought was that it might be a timing issue (VFP was still creating the folder when the code above hits, etc), so I placed a 2 second wait window immediately after creating the folder (and immediately above the code shown above) and it had no effect.
>
>Literally it is random. SMITHJ sometimes has the proper permissions and sometimes he's not assigned as a user for the folder at all.
>
>NOTE: If I run only one record for a test, it works properly every time. (Another reason I was suspicious that it might be a timing issue).
>
>Anyone have any suggestions? I'm totally baffled.... lol :-)
>
>Thanks,
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform