Thanks for answering. As I mentioned in the original post, I did the error checking after every ADSI call and got a 0 return code, I figured my sample code might be clearer if I omitted it.

I don't know for sure about having to do another GetObject. It's possible that it works that way, but I've never read anything about having to do that, and I've read the chapter that you recommended (several times), at least 20 nodes here at perlmonks about ADSI, and perhaps 50 other web pages about ADSI programming. Most of those pages use VB in their examples, but I think for the most part, the ADSI stuff has a one-to-one translation between VB and Perl. I did see a VB example on MSDN that suggests that you don't have to do that. The page at: http://technet.microsoft.com/en-us/library/ee156502.aspx shows writing an attribute, doing a SetInfo, then reading the attribute back in without doing another GetObject. I've snipped out most of the code just to keep this short and readable.

Set objUser = _ GetObject("LDAP://cn=MyerKen,ou=HR,dc=NA,dc=fabrikam,dc=com") '<snip> objUser.Put "givenName", "Ken" '<snip> objUser.SetInfo '<snip> strGivenName = objUser.Get("givenName") '<snip> Wscript.Echo "givenName: " & strGivenName

I figured all along that doing GetObject again would work (and I verified that this evening). I wanted to try to avoid that if possible, as I had designed the program around creating the connection once, and keeping it open for the duration of the program, then letting it close at the end.

I want to fully credit you with your suggestion about GetObject, because even though I believed it would work, until you suggested it I never considered it as a workaround. I was planning on opening the connection at the beginning of the program and closing it at the end. Without boring you with the details, what I can do is actually create one connection that I keep open like I was planning to do, and since I only have one object that I need to read, write, then read from, I will use a second connection for that and open it and close it as I need to do the reads and writes.


In reply to Re^2: Setting Attribute Values with ADSI by ItsMe2003
in thread Setting Attribute Values with ADSI by ItsMe2003

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.