Beranda > Script > Script merubah attribute Active Directory

Script merubah attribute Active Directory

Script dibawah adalah untuk mengedit attribute user, dan contoh script ini untuk hiden exchange address list dan disable OCS. Sebelum menjalankan script ini, buatkan terlebih dahulu file .txt yang akan di isi samAccountName.

Option Explicit
Dim strUser, rootDSE, adoConnection, ldapStr, adoRecord, objUser, objFso, objSrc

Set rootDSE = GetObject(“LDAP://RootDSE“)
Set adoConnection = CreateObject(“ADODB.Connection”)
adoConnection.Provider = “ADSDSOObject”
adoConnection.Open “ADs Provider”

Set objFso = CreateObject(“Scripting.FileSystemObject”)
Set objSrc = objFSO.OpenTextFile(“D:\src.txt”, 1)

While not objSrc.AtEndOfStream
  
strUser = objSrc.Readline

  ldapStr = “<LDAP://” & rootDSE.Get(“defaultNamingContext”) & “>;(&(objectCategory=Person)(objectClass=User)(samAccountName=” & strUser & “));adspath;subtree”

  Set adoRecord = adoConnection.Execute(ldapStr)
  If Not adoRecord.EOF Then
    On Error Resume Next
        Set objUser = GetObject (adoRecord.Fields(0).Value)
        objUser.Put “MSExchHideFromAddressLists”, “TRUE”   ‘–> hide from  exchange address list 
        objUser.Put “msRTCSIP-UserEnabled”, “FALSE”   ‘–> disable user for Office Communications Server (OCS)
        objUser.SetInfo
    On Error GoTo 0
 End If

wend

msgbox “Done”

Semoga bermanfaat,

Nana Sutisna

Iklan
Kategori:Script
  1. Belum ada komentar.
  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google+

You are commenting using your Google+ account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s

%d blogger menyukai ini: