<!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&nbsp;<SPAN class=959204517-13032007>to </SPAN>have a perl cgi 
script&nbsp;running on our intranet obtain the&nbsp;username/userid from Active 
Directory.&nbsp;&nbsp; </FONT></SPAN></DIV>
<DIV><SPAN class=291563417-13032007><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=291563417-13032007><FONT face=Arial size=2>Our environment here 
has AD used throughout the enterprise.&nbsp; The web server involved is IHS (IBM 
Http Server - based on Apache) running on Win2000.&nbsp; Again this is only used 
by internal users.</FONT></SPAN></DIV>
<DIV><SPAN class=291563417-13032007><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</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>&nbsp;&nbsp;Here<SPAN 
class=959204517-13032007>'s</SPAN> the code:</FONT></SPAN></DIV>
<DIV><SPAN class=291563417-13032007><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=291563417-13032007><FONT size=2><FONT face=Arial><STRONG><SPAN 
class=959204517-13032007>&nbsp;&nbsp; </SPAN>print ("Content-Type: 
text/html\n\n&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;");</STRONG></FONT></FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2><STRONG></STRONG></FONT>&nbsp;</DIV>
<DIV><SPAN class=291563417-13032007><FONT size=2><FONT face=Arial><STRONG><SPAN 
class=959204517-13032007>&nbsp;&nbsp; </SPAN>my $sysinfo = 
Win32::OLE-&gt;new('ADSystemInfo') || print ("&lt;BR&gt;Error line 
18&lt;BR&gt;");<BR><SPAN class=959204517-13032007>&nbsp;&nbsp; </SPAN>my 
$username=$sysinfo-&gt;{UserName};<BR><SPAN 
class=959204517-13032007>&nbsp;&nbsp; </SPAN>my $adsuser = 
Win32::OLE-&gt;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 ("&lt;BR&gt;Error line 24&lt;BR&gt;");<BR><SPAN 
class=959204517-13032007>&nbsp;&nbsp; </SPAN>my $name = 
$adsuser-&gt;{cn};</STRONG></FONT></SPAN></DIV><SPAN class=291563417-13032007>
<DIV><BR><FONT size=2><FONT face=Arial><STRONG><SPAN 
class=959204517-13032007>&nbsp;&nbsp; </SPAN>print 
("Username:$username&lt;BR&gt;Name:$name&lt;BR&gt;");&nbsp;<BR><SPAN 
class=959204517-13032007>&nbsp;&nbsp; </SPAN>print ("&lt;/<SPAN 
class=959204517-13032007>body</SPAN>&gt;&lt;/<SPAN 
class=959204517-13032007>html</SPAN>&gt;");</STRONG></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT></SPAN>&nbsp;</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.&nbsp; </SPAN></SPAN><SPAN class=291563417-13032007>When I run 
it on the server as a cgi, the username comes back blank.&nbsp; 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>&nbsp;</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 &amp; Agency Support</FONT> <BR><FONT face=@SimSun 
color=#ff0000>x1540<I></I></FONT><I></I> </P>
<DIV>&nbsp;</DIV></BODY></HTML>