Salut,
Est ce qql peut m'envoyer un petit script en perl pour interoger Active directory pour avoir une liste utilisateurs et emails.
Merci beaucoup.
Version imprimable
Salut,
Est ce qql peut m'envoyer un petit script en perl pour interoger Active directory pour avoir une liste utilisateurs et emails.
Merci beaucoup.
Salut,
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 # This Perl code finds all user accounts in a domain. # --------------------------------------------------------------- # Provided as a web-only addition for the book: # "Active Directory Cookbook" by Robbie Allen # Publisher: O'Reilly and Associates # ISBN: 0-596-00466-4 # Book web site: http://rallenhome.com/books/adcookbook/code.html # --------------------------------------------------------------- # ------ SCRIPT CONFIGURATION ------ my $strDomainDN = "<DomainDN>"; # e.g. dc=rallencorp,dc=com # ------ END CONFIGURATION --------- use Win32::OLE; $Win32::OLE::Warn = 3; my $strBase = "<LDAP://" . $strDomainDN . ">;"; # To search the whole forest using the global catalog, uncomment the following line: # $strBase = "<GC://" . $strDomainDN . ">;"; my $strFilter = "(&(objectclass=user)(objectcategory=person));"; my $strAttrs = "name;"; my $strScope = "subtree"; my $objConn = Win32::OLE->CreateObject("ADODB.Connection"); $objConn->{Provider} = "ADsDSOObject"; $objConn->Open; my $objRS = $objConn->Execute($strBase . $strFilter . $strAttrs . $strScope); $objRS->MoveFirst; while (not $objRS->EOF) { print $objRS->Fields(0)->Value,"\n"; $objRS->MoveNext; }
Merci Kuzco.