Forum

Active Directory Ot...
 
Bildirimler
Hepsini Temizle

Active Directory Otomatik Hesap Silme

10 Yazılar
5 Üyeler
0 Likes
1,345 Görüntüleme
(@MertKSK)
Gönderiler: 11
Active Member
Konu başlatıcı
 

İyi Çalışmalar Arkadaşlar ;


Yöneticisi olduğuım şirkette 150 ye yakın user var sürekli personel değişimi oluyor. Bir çok kez çıkan arkadaşın bize bilgisi dahi gelmiyor Bu nedenle Active Directory den otomatik olarak silinme tanımlamak istiyorum. 30 gün veya 60 gün servera giriş yapmayan kullanıcı direk silinsin istiyorum. Bunu yapabilen Script ya policy ayarı biliyormusunuz ?

 
Gönderildi : 08/01/2010 15:04

(@www-rizasahan-com)
Gönderiler: 18026
_
 

Merhaba, 


Active directory server isşetim sisteminiz nedir?

1984 doğumluyum. 4 yaşından bu yana İstanbul’da yaşıyorum. Sırası ile aşağıdaki okullarda eğitim gördüm. Paşaköy ilkokulu (1990-1995) Kartal Zekeriyya Güçer İlköğretim Okulu(1995-1998) Ümraniye Teknik ve Endüstri Meslek Lisesi Bilgisayar Bölümü(1998-2001) Kocaeli Üniversitesi Bilgisayar Programcılığı(2002-2004) Anadolu Ünv. İşletme Fakültesi(2006-2009) Lise yıllarından sonra bir bilgisayar firmasının teknik servisinde mesleğe merhaba dedim. Outsource olarak Citibank ytl ve bina taşınma projesinde yer alarak 8 ay görev yaptım. Bu görevden sonra şu an çalışmakta olduğum yerde bilgi işlem sorumlusu olarak göreve başladım ve 18 yıldır görevimin başındayım.

 
Gönderildi : 08/01/2010 16:41

(@MertKSK)
Gönderiler: 11
Active Member
Konu başlatıcı
 

Merhabalar Riza bey


Server 2003 Kullanıyorum

 
Gönderildi : 08/01/2010 16:48

(@www-rizasahan-com)
Gönderiler: 18026
_
 

Merhaba script burada ama otomatik silme işlemi konusunda biraz araştırma yapmak lazım.

Set objOU = GetObject(“LDAP://ou=istanbulOU,dc=serverismi dc=com”)


objOU.Delete “group”, “muhasebe”

1984 doğumluyum. 4 yaşından bu yana İstanbul’da yaşıyorum. Sırası ile aşağıdaki okullarda eğitim gördüm. Paşaköy ilkokulu (1990-1995) Kartal Zekeriyya Güçer İlköğretim Okulu(1995-1998) Ümraniye Teknik ve Endüstri Meslek Lisesi Bilgisayar Bölümü(1998-2001) Kocaeli Üniversitesi Bilgisayar Programcılığı(2002-2004) Anadolu Ünv. İşletme Fakültesi(2006-2009) Lise yıllarından sonra bir bilgisayar firmasının teknik servisinde mesleğe merhaba dedim. Outsource olarak Citibank ytl ve bina taşınma projesinde yer alarak 8 ay görev yaptım. Bu görevden sonra şu an çalışmakta olduğum yerde bilgi işlem sorumlusu olarak göreve başladım ve 18 yıldır görevimin başındayım.

 
Gönderildi : 08/01/2010 16:55

(@Anonim)
Gönderiler: 0
 


Merhabalar Riza bey


Server 2003 Kullanıyorum



Mert KSK,


Benim bildiğim kadarıyla böyle bir script yok.Ancak aşağıdaki script'i kendi yapına göre özelleştirip Expire olmuş olan Userları silebilir veya Disabled yapabilirsin.


İstediğin bir script için bence ScriptCenter'a göz atmanda fayda var.


 


Option Explicit


Const ADS_SCOPE_SUBTREE = 2


Dim oRootDSE, DNSDomain
Dim oConnection, oCommand, oRS
Dim GununTarihi
Dim HesapDN, dizin, fso


GununTarihi = Date()
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set oRootDSE = GetObject(“LDAP://RootDSE”)
DNSDomain = oRootDSE.Get(“DefaultNamingContext”)


Set oConnection = CreateObject(“ADODB.Connection”)
Set oCommand = CreateObject(“ADODB.Command”)
oConnection.Provider = “ADsDSOObject”
oConnection.Open “Active Directory Provider”
Set oCommand.ActiveConnection = oConnection
oCommand.Properties(“Page Size”) = 1000
oCommand.Properties(“Searchscope”) = ADS_SCOPE_SUBTREE
oCommand.CommandText = “SELECT distinguishedName FROM ‘LDAP://” & DNSDomain & “‘ ” & _
“WHERE objectCategory = ‘User’”
Set oRS = oCommand.Execute


oRS.MoveFirst
Do Until oRS.EOF
HesapDN = oRS.Fields(“distinguishedName”).Value
‘ExpireOlmusUserSil(HesapDN)         ‘Bu satır açık iken hesap silme çalışır
ExpireOlmusUserDisabled(HesapDN)     ‘Bu satır açık iken hesap disabled çalışır
oRS.MoveNext
Loop


Sub ExpireOlmusUserSil(Hesap)
Dim oUser, objOU, tarih ,Container, n


Container = “”
Set oUser = GetObject(“LDAP://” & Hesap)
On Error Resume Next
tarih = oUser.AccountExpirationDate


If tarih > “1/1/1970″ Then
If Err.Number = -2147467259 Then
Err.Clear
ElseIf tarih <= GununTarihi Then
Wscript.Echo “Silinen Hesap: ” & Hesap & ” ” & oUser.AccountExpirationDate & ” and userhome: ” & oUser.homeDirectory
If fso.FolderExists(oUser.homeDirectory) Then
fso.DeleteFolder oUser.homeDirectory, True
End If
dizin = Split(Hesap, “,”)
For n = 1 to UBound(dizin)
Container = Container & dizin(n) & “,”
Next
Container = Left(Container, Len(Container) – 1)
Set objOU = GetObject(“LDAP://” & Container)
objOU.Delete “user”, dizin(0)
End If
End If
On Error GoTo 0
End Sub


Sub ExpireOlmusUserDisabled(Hesap)
Dim oUser, objOU, tarih ,Container, n
Const ADS_UF_ACCOUNTDISABLE = 2
Container = “”
Set oUser = GetObject(“LDAP://” & Hesap)
On Error Resume Next
tarih = oUser.AccountExpirationDate


If tarih > “1/1/1970″ Then
If Err.Number = -2147467259 Then
Err.Clear
ElseIf tarih <= GununTarihi Then


Set objUser = GetObject _
(“LDAP://cn=” & Hesap %,ou=management,dc=fabrikam,dc=com”)
intUAC = objUser.Get(“userAccountControl”)


objUser.Put “userAccountControl”, intUAC OR ADS_UF_ACCOUNTDISABLE
objUser.SetInfo


End If
End If
End If
On Error GoTo 0
End Sub


 

 
Gönderildi : 08/01/2010 17:33

(@egemengungor)
Gönderiler: 8
Active Member
 

Aslında server 2008 kullanmış olsaydın Bir PowerShell Script var. İşine yararsa diye kodlar aşağıda belki başka arkadaşların işine yarar diye koymayı uygun gördüm.
Scriptin işleyişi: önce account u 90 gün içinde kullanılmazsa disable ediyor ve 30 gün sonrada otomatik siliyor.

 

# Uses Quest Active Roles  
# Free to download  http://www.quest.com/powershell/activeroles-server.aspx   
 
# Get all users in that have not logged on within  
# XXX days in "Active Directory" and Disable them  
 
# Get the Current Date  
 
$COMPAREDATE=GET-DATE  
 
# Number of Days to check back.  90 days  
 
$NumberDays=90  
 
# Number of Days to check for REALLY Stale accounts  
# Our sample here is taking "OldAccounts" and pumping up  
# 30 more days.  Therefore 120 days old accounts that haven't  
# logged in should be purged  
 
$DeleteDate=$NumberDays+30  
 
# We have certain "Override fields" that bypass a delete  
# happening.  If the "Notes" field in A/D contains the  
# EXACT Override phrase ANYWHERE (in this case it is the  
# word OVERRIDE and it IS case sensitive  
# The account will NEVER be deleted (unless of course you remove  
# Word from the Notes field  
 
#$OverRide='OVERRIDE 
 
# The other override field is if  
# the OnLeave details are in the Description  
# Field in A/D.  this allows for a User who is  
# Not gone (IE: Contractor / Student) but may  
# Return to have the account disabled and  
# Left alone until they return.  The words here are  
# simple On Leave Until and can be ANYWHERE in the  
# Description Field in A/D  
 
$OnLeave='On Leave Until'  
 
# Organizational Unit to search – This is in the fictional domain of  
# ‘Contoso.local’ in the OU of Users under the Business OU on the Root  
# of the Contoso A/D  
 
$OU='Contoso.local/Business/Users'  
 
# Get all users not active within the specified range and disable the accounts in Active Directory  
 
# We store them away as a variable since we're going to examine the list a few times.  
 
$LISTOFACCOUNTS=GET-QADUSER -SearchRoot $OU | where { $_.LastLogon.AddDays($NumberDays-gt $CURRENTDATE }  
 
# Any account not logged in within the short range gets Disabled in AD  
 
$LISTOFACCOUNTS | DISABLE-QADUSER -whatif  
 
# Pull up a new list.   Really old accounts  
 
$LISTOFPOTENTIALDELETES=$LISTOFACCOUNTS | where { $_.LastLogon.AddDays($DeleteDate) –gt $CURRENTDATE }  
 
# Secondary compare is more interesting.  If the accounts are VERY stale, they get deleted UNLESS special keywords  
# are in place  
 
 
 
FOREACH ($USER in $LISTOFPOTENTIALDELETES)  
{  
    IF (($USER.Notes -notlike '*'+$OVERRIDE+'*'-and ($USER.Description -notlike '*'+$OnLeave+'*'))  
    {  
        REMOVE-QADOBJECT $USER.Name -whatif  
        WRITE-HOST $USER.Name 'Deleted'  
    }  
    ELSEIF ($USER.Notes -like '*'+$OVERRIDE+'*')  
        {  
            WRITE-HOST $USER.Name 'Not removed due to Administrative Override'  
        }  
        ELSE  
        {  
            WRITE-HOST $USER.Name 'Not removed - Presently on Leave'  
        }  
}  

 
Gönderildi : 02/05/2012 19:17

(@mehmetyayla)
Gönderiler: 544
Honorable Member

(@mehmetyayla)
Gönderiler: 544
Honorable Member

(@egemengungor)
Gönderiler: 8
Active Member
 

Bir script daha :  http://gallery.technet.microsoft.com/scriptcenter/3a2377e0-4471-4eba-9dbd-5cfb9a4fdb28

  

Zaten benim gönderdiğim scriptin aynısı 😀

 
Gönderildi : 03/05/2012 13:41

(@mehmetyayla)
Gönderiler: 544
Honorable Member
 

Egemen bey kardeşim, scriptin 2003 desteği yok diye yazmışsın. Ben onun için tekrar yazdım:) Destekliyor...

 
Gönderildi : 04/05/2012 03:11

Paylaş: