<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1589" name=GENERATOR></HEAD>
<BODY>
<DIV>
<DIV><SPAN class=291563417-13032007><FONT face=Arial size=2>I am
trying <SPAN class=959204517-13032007>to </SPAN>have a perl cgi
script running on our intranet obtain the username/userid from Active
Directory. </FONT></SPAN></DIV>
<DIV><SPAN class=291563417-13032007><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=291563417-13032007><FONT face=Arial size=2>Our environment here
has AD used throughout the enterprise. The web server involved is IHS (IBM
Http Server - based on Apache) running on Win2000. Again this is only used
by internal users.</FONT></SPAN></DIV>
<DIV><SPAN class=291563417-13032007><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=291563417-13032007><FONT face=Arial size=2>I've written this as
a script using Win32::OLE<SPAN
class=959204517-13032007>.</SPAN> Here<SPAN
class=959204517-13032007>'s</SPAN> the code:</FONT></SPAN></DIV>
<DIV><SPAN class=291563417-13032007><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=291563417-13032007><FONT size=2><FONT face=Arial><STRONG><SPAN
class=959204517-13032007> </SPAN>print ("Content-Type:
text/html\n\n<html><head></head><body>");</STRONG></FONT></FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2><STRONG></STRONG></FONT> </DIV>
<DIV><SPAN class=291563417-13032007><FONT size=2><FONT face=Arial><STRONG><SPAN
class=959204517-13032007> </SPAN>my $sysinfo =
Win32::OLE->new('ADSystemInfo') || print ("<BR>Error line
18<BR>");<BR><SPAN class=959204517-13032007> </SPAN>my
$username=$sysinfo->{UserName};<BR><SPAN
class=959204517-13032007> </SPAN>my $adsuser =
Win32::OLE->GetObject("</STRONG></FONT></FONT><A
href="ldap://$username"><FONT face=Arial
size=2><STRONG>LDAP://$username</STRONG></FONT></A><FONT face=Arial
size=2><STRONG>") || print ("<BR>Error line 24<BR>");<BR><SPAN
class=959204517-13032007> </SPAN>my $name =
$adsuser->{cn};</STRONG></FONT></SPAN></DIV><SPAN class=291563417-13032007>
<DIV><BR><FONT size=2><FONT face=Arial><STRONG><SPAN
class=959204517-13032007> </SPAN>print
("Username:$username<BR>Name:$name<BR>"); <BR><SPAN
class=959204517-13032007> </SPAN>print ("</<SPAN
class=959204517-13032007>body</SPAN>></<SPAN
class=959204517-13032007>html</SPAN>>");</STRONG></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT></SPAN> </DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN class=291563417-13032007><SPAN
class=959204517-13032007>When I run this on my own workstation everything works
as I would like. </SPAN></SPAN><SPAN class=291563417-13032007>When I run
it on the server as a cgi, the username comes back blank. I suspect that
the cgi is running without AD information available, but am told otherwise by
technical resources here<SPAN
class=959204517-13032007>.</SPAN></SPAN></FONT></FONT></DIV>
<DIV><SPAN class=291563417-13032007></SPAN><SPAN class=291563417-13032007><FONT
face=Arial size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=291563417-13032007><FONT face=Arial size=2>Is there any way to
get the username in this situation?</FONT></SPAN></DIV></DIV>
<P><FONT face=@SimSun color=#ff0000>Ryan Davis</FONT> <BR><FONT face=@SimSun
color=#ff0000>Web & Agency Support</FONT> <BR><FONT face=@SimSun
color=#ff0000>x1540<I></I></FONT><I></I> </P>
<DIV> </DIV></BODY></HTML>