Forum

Active Directory &#...
 
Bildirimler
Hepsini Temizle

Active Directory Çoklu Kullanıcı Oluturma

2 Yazılar
2 Üyeler
0 Reactions
647 Görüntüleme
(@YukselYILMAZ)
Gönderiler: 3
Active Member
Konu başlatıcı
 

İyi günler,


arkadaşlar çok bir excel doyasında bulunan bilgileri (İsim Soyadı,telefon,organizayon,profil vb ) nasıl yaparımda bir script vasıtasyla active directoryde kullanıcıyı oluşturup ilgili ou içinde oluşturup ve bilgi tablarını doldurabilirim.


Yada bunun daha başka yöntemleri varmıdır.Kullanıcı sayısı çok ama çok fazla.3000 desem yalan olmaz herhalde

 
Gönderildi : 06/10/2009 11:42

(@cenkbalci)
Gönderiler: 72
Trusted Member
 

Merhaba,


 


Öncelikle bu script ile 3000 tane user oluşturun;


Set objRootDSE = GetObject("LDAP://rootDSE")

Set objContainer = GetObject("LDAP://cn=Users," & _
    objRootDSE.Get("defaultNamingContext"))

For i = 1 To 3000
    Set objLeaf = objContainer.Create("User", "cn=UserNo" & i)
    objLeaf.Put "sAMAccountName", "UserNo" & i
    objLeaf.SetInfo
Next

WScript.Echo "3000 Users created."


 


Bunları Users containerı içinde oluşturacak.Bunları manuel olarak ilgili OU ya taşıdıktan sonra,Bu script ile istenilen alanları değiştirebilirsiniz.


' UpdateUserProfile2.vbs
' VBScript program to update the Değiştirilecek Alan attribute of user objects
' according to the information in a spreadsheet.
'
' ----------------------------------------------------------------------
' Copyright (c) 2004 Richard L. Mueller
' Hilltop Lab web site - http://www.rlmueller.net
' Version 1.0 - January 13, 2004
' Version 1.1 - January 25, 2004 - Modify error trapping.
' Version 1.2 - March 18, 2004 - Modify NameTranslate constants.
' Version 1.3 - July 30, 2007 - Escape any "/" characters in User DN's.
'
' The input spreadsheet is a list of the NT logon name of each user
' whose Değiştirilecek Alan attribute will be updated, one name per row. The
' user names are in the first column. The value to be assigned to the
' Değiştirilecek Alan attribute is in the second column. The first row is
' skipped. The program processes each row until a blank entry is
' encountered in the first column. If the entry in the second column is
' the special value ".delete", the program will clear the Değiştirilecek Alan
' attribute for that user. The program uses the NameTranslate object to
' convert the  NT name of the user (the sAMAccountName attribute) to the
' Distinguished Name required to bind to the user object with the LDAP
' provider.
'
' You have a royalty-free right to use, modify, reproduce, and
' distribute this script file in any way you find useful, provided that
' you agree that the copyright owner above has no warranty, obligations,
' or liability for such use.


Option Explicit


Const ADS_PROPERTY_CLEAR = 1
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1


Dim strExcelPath, objExcel, objSheet, intRow, strUserDN, strDeğiştirilecek Alan
Dim objUser, strUserNTName
Dim objRootDSE, strDNSDomain, objTrans, strNetBIOSDomain


' Check for required arguments.
If (Wscript.Arguments.Count < 1) Then
    Wscript.Echo "Argument <SpreadsheetName> required. For example:" _
        & vbCrLf _
        & "cscript UpdateUserProfile2.vbs c:\MyFolder\UserList.xls"
    Wscript.Quit(0)
End If


' Spreadsheet file.
strExcelPath = Wscript.Arguments(0)


' Bind to Excel object.
On Error Resume Next
Set objExcel = CreateObject("Excel.Application")
If (Err.Number <> 0) Then
    On Error GoTo 0
    Wscript.Echo "Excel application not found."
    Wscript.Quit
End If
On Error GoTo 0


' Open spreadsheet.
On Error Resume Next
objExcel.Workbooks.Open strExcelPath
If (Err.Number <> 0) Then
    On Error GoTo 0
    Wscript.Echo "Spreadsheet cannot be opened: " & strExcelPath
    Wscript.Quit
End If
On Error GoTo 0


' Bind to worksheet.
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)


' Determine DNS domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")


' Use the NameTranslate object to find the NetBIOS domain name
' from the DNS domain name.
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_INITTYPE_GC, ""
objTrans.Set ADS_NAME_TYPE_1779, strDNSDomain
strNetBIOSDomain = objTrans.Get(ADS_NAME_TYPE_NT4)
' Remove trailing backslash.
strNetBIOSDomain = Left(strNetBIOSDomain, _
    Len(strNetBIOSDomain) - 1)


' The first row of the spreadsheet is skipped (column headings). Each
' row after the first is processed until the first blank entry in the
' first column is encountered. The first column is the NT user name of
' the user, the second column is the new Değiştirilecek Alan. The loop binds to
' each user object and assigns the new value for the attribute. intRow
' is the row number of the spreadsheet.
' Use the NameTranslate object to convert the NT user names
' to the Distinguished Name required for the LDAP provider.
intRow = 2
Do While objSheet.Cells(intRow, 1).Value <> ""
    strUserNTName = Trim(objSheet.Cells(intRow, 1).Value)
    ' Use NameTranslate to convert NT name to Distinguished Name.
    On Error Resume Next
    objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & strUserNTName
    If (Err.Number <> 0) Then
        On Error GoTo 0
        Wscript.Echo "User " & strUserNTName _
            & " not found in Active Directory"
    End If
    On Error GoTo 0
    strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)
    ' Escape any forward slash characters, "/", with the backslash
    ' escape character. All other characters that should be escaped are.
    strUserDN = Replace(strUserDN, "/", "\/")


    strDeğiştirilecek Alan = Trim(objSheet.Cells(intRow, 2).Value)
    If (strDeğiştirilecek Alan <> "") Then
        On Error Resume Next
        Set objUser = GetObject("LDAP://" & strUserDN)
        If (Err.Number <> 0) Then
            On Error GoTo 0
            Wscript.Echo "User NOT found " & strUserDN
        Else
            On Error GoTo 0
            If (LCase(strDeğiştirilecek Alan) = ".delete") Then
                On Error Resume Next
                objUser.PutEx ADS_PROPERTY_CLEAR, "Değiştirilecek Alan", 0
                objUser.SetInfo
                If (Err.Number <> 0) Then
                    On Error GoTo 0
                    Wscript.Echo "Unable to clear Değiştirilecek Alan for user " _
                        & strUserDN
                End If
                On Error GoTo 0
            Else
                objUser.Değiştirilecek Alan = strDeğiştirilecek Alan
                On Error Resume Next
                objUser.SetInfo
                If (Err.Number <> 0) Then
                    On Error GoTo 0
                    Wscript.Echo "Unable to set Değiştirilecek Alan for user " _
                        & strUserDN
                End If
                On Error GoTo 0
            End If
        End If
    End If
    intRow = intRow + 1
Loop


' Close the workbook.
objExcel.ActiveWorkbook.Close


' Quit Excel.
objExcel.Application.Quit


' Clean up.
Set objUser = Nothing
Set objExcel = Nothing
Set objSheet = Nothing
Set objRootDSE = Nothing
Set objTrans = Nothing


Wscript.Echo "Done"



 

 
Gönderildi : 06/10/2009 12:06

Paylaş: