Fetstil Fetstil Kursiv Understrykning linje färgläggning tabellverk Punktlista Nummerlista Vänster Centrerat högerställt Utfyllt Länk Bild htmlmode
  • Forum & Blog
    • Forum - översikt
      • .Net
        • asp.net generellt
        • c#
        • vb.net
        • f#
        • silverlight
        • microsoft surface
        • visual studio .net
      • databaser
        • sql-server
        • databaser
        • access
        • mysql
      • mjukvara klient
        • datorer och komponenter
        • nätverk, lan/wan
        • operativsystem
        • programvaror
        • säkerhet, inställningar
        • windows server
        • allmänt
        • crystal reports
        • exchange/outlook
        • microsoft office
      • mjukvara server
        • active directory
        • biztalk
        • exchange
        • linux
        • sharepoint
        • webbservers
        • sql server
      • appar (win/mobil)
      • programspråk
        • c++
        • delphi
        • java
        • quick basic
        • visual basic
      • scripting
        • asp 3.0
        • flash actionscript
        • html css
        • javascript
        • php
        • regular expresssion
        • xml
      • spel och grafik
        • DirectX
        • Spel och grafik
      • ledning
        • Arkitektur
        • Systemutveckling
        • krav och test
        • projektledning
        • ledningsfrågor
      • vb-sektioner
        • activeX
        • windows api
        • elektronik
        • internet
        • komponenter
        • nätverk
        • operativsystem
      • övriga forum
        • arbete karriär
        • erbjuda uppdrag och tjänster
        • juridiska frågor
        • köp och sälj
        • matematik och fysik
        • intern information
        • skrivklåda
        • webb-operatörer
    • Posta inlägg i forumet
    • Chatta med andra
  • Konto
    • Medlemssida
    • Byta lösenord
    • Bli bonsumedlem
    • iMail
  • Material
    • Tips & tricks
    • Artiklar
    • Programarkiv
  • JOBB
  • Student
    • Studentlicenser
  • KONTAKT
    • Om pellesoft
    • Grundare
    • Kontakta oss
    • Annonsering
    • Partners
    • Felanmälan
  • Logga in

Hem / Forum översikt / inlägg

Posta nytt inlägg


Script för att hämta ut användare ur AD

Postades av 2006-01-09 16:44:34 - Tobias Fridlund, i forum active directory, Tråden har 0 Kommentarer och lästs av 1804 personer

Hej

Jag har ett script som jag använder för att hämta ut information om användare ur AD:t. Dom källor jag har använt och på det viset som det har blivit uppbyggt medför att jag bara kan få ut information ur 1 OU åt gången. Finns det något sätt att göa så att detta scriptet känner av om det finns en OU under den nivå den är på och automatiskt går in även i nästa nivå och tar fram info ur det eller måste jag byta ut vilket OU det är som gäller varje gång.

Kanske det är så att jag kan specificera flera OU åt gången, det är också acceptabelt, men inte heller detta har jag fått att fungera.

Tacksam för all hjälp med detta.

/T

<code>
'
' This script extracts user data from the AD-OU Specified below, you need to change it
' Data is saved in Excel format in the file c:\test.xls
' The excel file can then be edited, but not the RED marked colums and imported with the
' import script.
'

'On Error Resume Next

Set objExcel = CreateObject("Excel.Application")
objexcel.Visible = False
objexcel.Workbooks.add

inti = 0
intRow = 2

Set objOU = GetObject("LDAP://OU=CU 1,OU=BU 10,OU=BA 100,OU=mitt bolag,DC=ad,DC=com")
objOU.Filter = Array("user")

For Each objUser in objOU
' Destinguished Name - Column A
objExcel.Cells(intRow, 1).Value = objUser.distinguishedName
ObjExcel.Cells(intRow, 1).Interior.ColorIndex = 3

' Sign - Column B
IF objuser.sAMAccountName = "" Then
ELSE
objExcel.Cells(intRow, 2).Value = objUser.sAMAccountName
ObjExcel.Cells(intRow, 2).Interior.ColorIndex = 3
END IF

' Given_Name - Column C
IF objuser.givenName = "" Then
ELSE
objExcel.Cells(intRow, 3).Value = objUser.givenName
END IF

' Surname - Column D
IF objuser.sn = "" Then
ELSE
objExcel.Cells(intRow, 4).Value = objUser.sn
END IF

' Common-Name - Column E
IF objuser.cn = "" Then
ELSE
objExcel.Cells(intRow, 5).Value = objUser.cn
ObjExcel.Cells(intRow, 5).Interior.ColorIndex = 3
END IF

' Employee-Number - Column F
IF objuser.employeeNumber = "" Then
ELSE
objExcel.Cells(intRow, 6).Value = objUser.employeeNumber
END IF

' Physical-Delivery-Office-Name - Column G
IF objuser.physicalDeliveryOfficeName = "" Then
ELSE
objExcel.Cells(intRow, 7).Value = objUser.physicalDeliveryOfficeName
END IF

' Address - Column H
IF objuser.streetAddress = "" Then
ELSE
objExcel.Cells(intRow, 8).Value = objUser.streetAddress
END IF

' Postal-Code - Column I
IF objuser.postalCode = "" Then
ELSE
objExcel.Cells(intRow, 9).Value = objUser.postalCode
END IF

' Locality-Name - Column J
IF objuser.l = "" Then
ELSE
objExcel.Cells(intRow, 10).Value = objUser.l
END IF

' Facsimile-Telephone-Number - Column K
IF objuser.facsimileTelephoneNumber = "" Then
ELSE
objExcel.Cells(intRow, 11).Value = ("'" & objUser.facsimileTelephoneNumber & "")
END IF

' Telephone-Number - Column L
IF objuser.telephoneNumber = "" Then
ELSE
objExcel.Cells(intRow, 12).Value = ("'" & objUser.telephoneNumber & "")
END IF

' Phone-Mobile-Primary - Column M
IF objuser.mobile = "" Then
ELSE
objExcel.Cells(intRow, 13).Value = ("'" & objUser.mobile & "")
END IF

' room-Number - Column N
IF objuser.roomNumber = "" Then
ELSE
objExcel.Cells(intRow, 14).Value = objUser.roomNumber
END IF

' Address-Home - Column O
IF objuser.homePostalAddress = "" Then
ELSE
objExcel.Cells(intRow, 15).Value = objUser.homePostalAddress
END IF

' Phone-Home-Primary - Column P
IF objuser.homePhone = "" Then
ELSE
objExcel.Cells(intRow, 16).Value = ("'" & objUser.homePhone & "")
END IF

' Company - Column Q
IF objuser.company = "" Then
ELSE
objExcel.Cells(intRow, 17).Value = objUser.company
END IF

' Division - Column R
IF objuser.division = "" Then
ELSE
objExcel.Cells(intRow, 18).Value = objUser.division
END IF

' Department - Column S
IF objuser.department = "" Then
ELSE
objExcel.Cells(intRow, 19).Value = objUser.department
END IF

' ms-Exch-Extension-Attribute-10 - Column T
IF objuser.extensionAttribute10 = "" Then
ELSE
objExcel.Cells(intRow, 20).Value = objUser.extensionAttribute10
END IF


intRow = intRow + 1
inti = inti + 1

Next

' Write the Header row to the Excel file

objExcel.Cells(1, 1).Value = "distinguishedName"
objExcel.Cells(1, 1).Font.Bold = TRUE
ObjExcel.Cells(1, 1).Interior.ColorIndex = 36

objExcel.Cells(1, 2).Value = "Sign"
objExcel.Cells(1, 2).Font.Bold = TRUE
ObjExcel.Cells(1, 2).Interior.ColorIndex = 36

objExcel.Cells(1, 3).Value = "Given_Name"
objExcel.Cells(1, 3).Font.Bold = TRUE
ObjExcel.Cells(1, 3).Interior.ColorIndex = 36

objExcel.Cells(1, 4).Value = "Surename"
objExcel.Cells(1, 4).Font.Bold = TRUE
ObjExcel.Cells(1, 4).Interior.ColorIndex = 36

objExcel.Cells(1, 5).Value = "Common-Name"
objExcel.Cells(1, 5).Font.Bold = TRUE
ObjExcel.Cells(1, 5).Interior.ColorIndex = 36

objExcel.Cells(1, 6).Value = "Employee-Number"
objExcel.Cells(1, 6).Font.Bold = TRUE
ObjExcel.Cells(1, 6).Interior.ColorIndex = 36

objExcel.Cells(1, 7).Value = "Physical-Delivery-Office-Name"
objExcel.Cells(1, 7).Font.Bold = TRUE
ObjExcel.Cells(1, 7).Interior.ColorIndex = 36

objExcel.Cells(1, 8).Value = "Address"
objExcel.Cells(1, 8).Font.Bold = TRUE
ObjExcel.Cells(1, 8).Interior.ColorIndex = 36

objExcel.Cells(1, 9).Value = "Postal-Code"
objExcel.Cells(1, 9).Font.Bold = TRUE
ObjExcel.Cells(1, 9).Interior.ColorIndex = 36

objExcel.Cells(1, 10).Value = "Locality-Name"
objExcel.Cells(1, 10).Font.Bold = TRUE
ObjExcel.Cells(1, 10).Interior.ColorIndex = 36

objExcel.Cells(1, 11).Value = "Facsimile-Telephone-Number"
objExcel.Cells(1, 11).Font.Bold = TRUE
ObjExcel.Cells(1, 11).Interior.ColorIndex = 36

objExcel.Cells(1, 12).Value = "Telephone-Number"
objExcel.Cells(1, 12).Font.Bold = TRUE
ObjExcel.Cells(1, 12).Interior.ColorIndex = 36

objExcel.Cells(1, 13).Value = "Phone-Mobile-Primary"
objExcel.Cells(1, 13).Font.Bold = TRUE
ObjExcel.Cells(1, 13).Interior.ColorIndex = 36

objExcel.Cells(1, 14).Value = "roomNumber"
objExcel.Cells(1, 14).Font.Bold = TRUE
ObjExcel.Cells(1, 14).Interior.ColorIndex = 36

objExcel.Cells(1, 15).Value = "Address-Home"
objExcel.Cells(1, 15).Font.Bold = TRUE
ObjExcel.Cells(1, 15).Interior.ColorIndex = 36

objExcel.Cells(1, 16).Value = "Phone-Home-Primary"
objExcel.Cells(1, 16).Font.Bold = TRUE
ObjExcel.Cells(1, 16).Interior.ColorIndex = 36

objExcel.Cells(1, 17).Value = "Company"
objExcel.Cells(1, 17).Font.Bold = TRUE
ObjExcel.Cells(1, 17).Interior.ColorIndex = 36

objExcel.Cells(1, 18).Value = "division"
objExcel.Cells(1, 18).Font.Bold = TRUE
ObjExcel.Cells(1, 18).Interior.ColorIndex = 36

objExcel.Cells(1, 19).Value = "department"
objExcel.Cells(1, 19).Font.Bold = TRUE
ObjExcel.Cells(1, 19).Interior.ColorIndex = 36

objExcel.Cells(1, 20).Value = "extensionAttribute10"
objExcel.Cells(1, 20).Font.Bold = TRUE
objExcel.Cells(1, 20).Interior.ColorIndex = 36

' Close and Save File

objexcel.ActiveWorkbook.SaveAs("c:\test.xls")
objExcel.Application.Quit
Wscript.Echo ("All Done, Processed " & inti & " entries")

If IsNull(curBonus) Then
CurBonus = 0
End If
</code>


Svara

Nyligen

  • 18:37 Remove the bumper in AUDI
  • 15:35 Chicken road crash game
  • 21:41 Automotive Services UK
  • 20:44 Erfarenhet av CBD-olja mot sömnpro
  • 12:13 Sex Dolls for Sale
  • 19:42 Online Casinos for Haitian Players
  • 19:38 Rekommendera något intressant
  • 19:13 Международная перевозка грузов

Sidor

  • Hem
  • Bli bonusmedlem
  • Läs artiklar
  • Chatta med andra
  • Sök och erbjud jobb
  • Kontakta oss
  • Studentlicenser
  • Skriv en artikel

Statistik

Antal besökare:
Antal medlemmar:
Antal inlägg:
Online:
På chatten:
4 570 893
27 965
271 778
554
0

Kontakta oss

Frågor runt konsultation, rådgivning, uppdrag, rekrytering, annonsering och övriga ärenden. Ring: 0730-88 22 24 | pelle@pellesoft.se

© 1986-2013 PelleSoft AB. Last Build 4.1.7169.18070 (2019-08-18 10:02:21) 4.0.30319.42000
  • Om
  • Kontakta
  • Regler
  • Cookies