Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

PERL en ADSI

by PerlUserNL (Initiate)
on Jan 11, 2011 at 10:58 UTC ( #881640=perlquestion: print w/ replies, xml ) Need Help??
PerlUserNL has asked for the wisdom of the Perl Monks concerning the following question:

I have to make a script and use ADSI or ado.

The script have to search Active directory for users with the same Front name.

If users where found with the same front name, the username must be write in the General field (in Active directorty)

example users:

(account name, fullname, firstname, lastname)

janj, Jan Jansen, Jan, Jansen

janp, Jan Pietersen Jan, Pietersen

janq, Jan Quota, Jan, Quota

jjameson, Jannie Jameson, Jannie, Jameson

Output in the General Field:

janj = janp, janq

janp = janj, janq

janq = janj, janp

jjameson = <empty >

Is there someone, wo can help me with this?

use strict; use warnings; use Win32::OLE; my $ou; my @filter; my $obj; $ou=Win32::OLE->GetObject("LDAP://ou=NID_Users,dc=A34,dc=NID"); @filter=("user"); $ou->{filter}=\@filter; print "Hier Volgt een lijst van gebruikers:\n"; foreach $obj (in $ou){ print "$obj->{name}\n"; print " First name: " ; print "$obj->{givenName}\n" ; print "###############\n\n\n" ; }

The code above is all what I made

Comment on PERL en ADSI
Download Code
Re: PERL en ADSI
by wazoox (Prior) on Jan 11, 2011 at 11:12 UTC

      I have made a step for step plan: First I want to get the overvieuw of the users. Then I want to compare the first names. Then I want to get the output of the users with the same name. Now i need to copy the usernames to the general field.

      use Win32::OLE; $ou=Win32::OLE->GetObject("LDAP://ou=Users,dc=myDomain,dc=net"); @filter=("user"); $ou->{filter}=\@filter; foreach $obj (in $ou){ print "$obj->{name}\n"; }

      Above code i want to use to get the user list. But i think i did something wrong, or maybe it can be done on a easier way.

        Yep.

        Add

        use strict; use warnings;
        To the top of that code, and Perl will tell you what is technically wrong and help get the code to run.

        You will save yourself from a million headaches if you use those liberally.

        (Appended)
        PS:
        A quick look through the Win32::OLE description indicates that your code probably won't compile because "in" isn't exported by default. You probably want to add that and anything else you want to use to your use statements up top.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://881640]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2014-07-22 07:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (106 votes), past polls