Hi Monks,
I have a problem that I cant seem to get around that I'm hoping someone can help with.
I'm writing a little app that will allow users to administer their own applications on a weekly basis (i.e we dont want to keep dealing with user requests for Visio but we dont want to give it to everyone either!)
I have the front end for the app done but my problem comes with the addition of the user to the required group in Active Directory.
The application runs via Citrix (compiled as an exe) and thus runs under the users own profile. We doont want to give the user rights to update AD (for obvious reasons) so the part of the script that does the group add has to run under an admin user banner.
So far, heres the addgroup sub I've come up with:
sub add2Grp { my $group = $_[0]; my $user = $_[1]; print "Adding: $group to: $user\n"; my $win32 = Win32::OLE->new('WScript.Shell') || die "Can not creat +e WScript Shell; $!\n"; my $result = $win32->Run('runas /noprofile /user:DOMAIN\\USER Net +Group $group $user /ADD /DOMAIN'); sleep(3); $win32->SendKeys('password~'); return "$result"; }
$group and $user are passed in correctly and the testing I've done so far with wscript (making it launch a cmd prompt under the elevated credentials) has worked.
However, I cant figure out how to get the data back from the NET ADD command? Basically, I want to return whatever the feedback is from the command line (which will either be "the command completed successfully" or some error) so that I can check within the program whether or not its worked.
At the minute, that return just gives me an OLE hashref and I cant figure out what value within that hash will give me what I want.
Can anyone help?
Also, feel free to tell me theres a better way to do this if there is one (running a certain part of the script as someoene else)
In reply to Win32::OLE and Wscript Shell -> Getting data back by Gaz5
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |