Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-26 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found