Hello Monks! I am an amatuer in Perl and have created a simple DB insert script that is giving login issues. The script is invoked by an application upon an event. The DB connection part of the script does not use credentials(user & pass). When I place the script in the C:\ of the application's server and run it from command line, it runs fine, but when I place the script in a mapped drive of the same server (accessible from other servers but meant only for this application) and invoke it via the application I get an error 'Login failed for user 'HASH(0x34882c)'(SQL-28000)'. I know the former is using the serviceacct credentials and hence succeeding but the latter is what has got me puzzled.

The not putting in the user and pass is a requirement by our infosec. I was asked to use Active Directory to use the credentials of the server the application is residing on. Since I am new to this aspect of Perl, I did some searching online and found that LDAP might be the way to go but I haven't played around with AD nor LDAP at all, so a little lost and would greatly appreciate any kind of help or direction. I have included below the DB piece of my code for reference. Also, I am on Windows Server Ent.

Thanks!
my $server_name = 'production\reporting'; my $database_name = 'test'; my $DSN = "driver={SQL Server};server=$server_name;database=$database_ +name;"; my $dbh = DBI->connect("dbi:ODBC:$DSN", {PrintError =>0, RaiseError => +1}); eval { if (!$dbh) { print "Could not connect to da +tabase: $DBI::errstr"; } if($dbh) { print "Connected to DB!!"; } my $sql = "INSERT INTO Count VALUES ()"; my $sth = $dbh->prepare($sql); $sth->execute(); }; if($@) { $dbh->disconnect(); QuitProgram("DB Failure: $@"); }

In reply to Perl with Active Directory by sowais

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.