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??
You really can't do much with Win32::Lanman and AD, as you are only really using NT funtion to achieve what you want, so there's no control over anything purely Win2K/AD related. You really need to use Win32::OLE to do what you're trying to. Here are a couple of user modification sibroutintes that I use;
sub ad_modify { # To change a single value in AD use Win32::OLE; my $dn = $_[0]; # The object DN my $attrib = $_[1]; # The attribute to change my $value = $_[2]; # The attributes new value my ($object); $object = Win32::OLE->GetObject("$dn"); $object->{$attrib} = "$value"; $object->SetInfo; # Don't forget to set the values } sub ad_get_attrib { # For returning Attribute Values.... use Win32::OLE; my $dn = $_[0]; # The object DN my $attrib = $_[1]; # The attribute in question my ($object,$result); $object = Win32::OLE->GetObject("$dn"); if ($object->{$attrib}) { # If this Attribute actually exists.... $result = $object->Get("$attrib"); } return $result; } sub ad_search { # To search AD and return a pre-determined value use Win32::OLE; my $search_base = $_[0]; # This is the base for our searches my $filter = $_[1]; # This is the valid LDAP filter that we will be ap +plying my $attribute = $_[2]; # This is the attribute that we will be returni +ng my $search_scope = $_[3]; # This is the scope for our search to follow my ($conn, $res, @result, $succ_search); # Variables that we are using + as we go $conn = Win32::OLE->new('ADODB.Connection'); # New connection $conn->{Provider} = "ADsDSOObject"; # OLE provider $conn->Open; $res = $conn->Execute($search_base . $filter . $attribute . $search_sc +ope); # This is our search if ($res->EOF) { # If we have found 0 records that match our search $succ_search = 0; # Set our no records found item and return it } else { $succ_search = 1; # So our records found item $res->MoveFirst; # Go to the first record while (not $res->EOF) { # Whie we still have records push (@result, $res->Fields(0)->Value); # Push them to our arr +ay $res->MoveNext; # Go to the next one } } return ($succ_search, @result); # Return our success and our array of +results }
You could use a mix of Win32::OLE and Win32::Lanman::NewUser to achieve that you want (Win32::OLE will also allow you to move objects to new containers), but I'd suggest doing a bit of research and using Win32::OLE to do the whole lot.

In reply to Re: Win32::Lanman::NetUserAdd by SquireJames
in thread Win32::Lanman::NetUserAdd by 3dbc

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 making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-26 00:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found