That's not a VBS, and it relies on external tools. I could convert the batch file to Perl, but it would still rely on the external tool. I don't think that's what the OP wants.

Update: Looks like I missed the code far down in the IFRAME. I'm not sure if I'm converting from the format you have, but the following should help you.

use strict; use warnings; use Win32::OLE (); # Constants for the NameTranslate object. use constant ADS_NAME_INITTYPE_GC => 3; use constant ADS_NAME_TYPE_1779 => 1; use constant ADS_NAME_TYPE_NT4 => 3; # Specify the Display Name of the user. my $nt_name = $ENV{USERDOMAIN} . '\\' . $ENV{USER}; # Use the NameTranslate object to convert the Display Name # of the user to the Distinguished Name. my $name_translate = Win32::OLE->new('NameTranslate') or die("Unable to load NameTranslate OLE object\n"); # Initialize NameTranslate by locating the Global Catalog. $name_translate->Init(ADS_NAME_INITTYPE_GC, ""); # Use the Set method to specify the NT of the object name. $name_translate->Set(ADS_NAME_TYPE_NT4, $nt_name); # Use the Get method to retrieve the Distinguished Name of the user. my $user_dn = $name_translate->Get(ADS_NAME_TYPE_1779); print("$nt_name => $user_dn\n");

For me, the output is

MYDOMAIN\myuser => CN=MyLast\, MyFirst,CN=Users,DC=mycompany,DC=biz

In reply to Re^3: convert the SamAccountName to the Distinguished name by using "NameTranslate" by ikegami
in thread convert the SamAccountName to the Distinguished name by using "NameTranslate" by SteveS832001

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.