Help with Win32::OLE

N

Ninja67

Thanks to Thomas Kratz on a previous post, I was able to take the code
he posted and get it to work with just a couple of small modifications.
Here is the code below:
#!C:/Perl/bin/perl.exe

use strict;
use warnings;

use Win32::OLE qw/in/;
Win32::OLE->Option(Warn => 1);

my($domain, $user) = split(/\\/,$ENV{'REMOTE_USER'});

my $path = "WinNT://$domain/$user";
print "Content-type:text/html\n\n";
print "domain=$domain<br />\nuser=$user<br />\npath=$path<br />\n";

my $o_user = Win32::OLE->GetObject($path) or die Win32::LastErr();

print "<br />\nGroup Memberships:<br />\n";
foreach my $group ( in($o_user->Groups()) ) {
print $group->Name, "<br />\n";
}

For test reasons, I'm just printing the results of the Groups() method
to the browser.

I have searched Google and the Perl docs and can not find a list of
methods other than Groups() that are available. Can someone point me
in the right direction? I am trying to see what other information I
can glean from the Win32::OLE->GetObject($path) method such as the
user's full name, etc.

Thanks.
 
B

Bob Walton

Ninja67 said:
Thanks to Thomas Kratz on a previous post, I was able to take the code
he posted and get it to work with just a couple of small modifications.
Here is the code below:
#!C:/Perl/bin/perl.exe

use strict;
use warnings;

use Win32::OLE qw/in/;
Win32::OLE->Option(Warn => 1);

my($domain, $user) = split(/\\/,$ENV{'REMOTE_USER'});

my $path = "WinNT://$domain/$user";
print "Content-type:text/html\n\n";
print "domain=$domain<br />\nuser=$user<br />\npath=$path<br />\n";

my $o_user = Win32::OLE->GetObject($path) or die Win32::LastErr(); Win32::OLE::LastError------------------------------^^^^^^^^^^^^^^

print "<br />\nGroup Memberships:<br />\n";
foreach my $group ( in($o_user->Groups()) ) {
print $group->Name, "<br />\n";
}

For test reasons, I'm just printing the results of the Groups() method
to the browser.

I have searched Google and the Perl docs and can not find a list of
methods other than Groups() that are available. Can someone point me
in the right direction? I am trying to see what other information I
can glean from the Win32::OLE->GetObject($path) method such as the
user's full name, etc.

Well, OLE is Micro$loth's thing, so you'll have to look for OLE
documentation in Micro$loth's documentation, if there even is
any. Usually you can find it, such as it is, using the target
application's "OLE browser". I don't have a clue where you would
look for that for what you're trying to do. Maybe an OLE
newsgroup might be the place to ask? There probably aren't many
OLE heavies here.
 
P

Peter Wyzl

:
: Well, OLE is Micro$loth's thing, so you'll have to look for OLE
: documentation in Micro$loth's documentation, if there even is
: any. Usually you can find it, such as it is, using the target
: application's "OLE browser". I don't have a clue where you would
: look for that for what you're trying to do. Maybe an OLE
: newsgroup might be the place to ask? There probably aren't many
: OLE heavies here.

Activestate provide an OLE browser with Activeperl. It is in the same
program group as the html documentation.

P
 
T

Thomas Kratz

Ninja67 said:
Thanks to Thomas Kratz on a previous post, I was able to take the code
he posted and get it to work with just a couple of small modifications.
Here is the code below:
#!C:/Perl/bin/perl.exe

use strict;
use warnings;

use Win32::OLE qw/in/;
Win32::OLE->Option(Warn => 1);

my($domain, $user) = split(/\\/,$ENV{'REMOTE_USER'});

my $path = "WinNT://$domain/$user";
print "Content-type:text/html\n\n";
print "domain=$domain<br />\nuser=$user<br />\npath=$path<br />\n";

my $o_user = Win32::OLE->GetObject($path) or die Win32::LastErr();

print "<br />\nGroup Memberships:<br />\n";
foreach my $group ( in($o_user->Groups()) ) {
print $group->Name, "<br />\n";
}

For test reasons, I'm just printing the results of the Groups() method
to the browser.

I have searched Google and the Perl docs and can not find a list of
methods other than Groups() that are available. Can someone point me
in the right direction? I am trying to see what other information I
can glean from the Win32::OLE->GetObject($path) method such as the
user's full name, etc.

As Bob already told you, Win32::OLE let you interact with various M$
services and programs over the OLE (or COM) interface. The thing you
need to work with is ADSI (Active Directory Service Interface). In the
example I posted, I used the "WinNT Provider".
You can find the M$ docs here:

http://tinyurl.com/c9k7o

But it may be quicker to google for examples on ADSI.

Thomas

--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top