Habe nun schon lange nichts mehr gepostet. Aber nun folgt mal etwas Code.
Ich habe eine Programm in VB.net geschrieben um User automatisiert anzulegen.
Diesen Code will ich hier posten:
Zuerst natürlich der Import
Imports System.DirectoryServices
Und dann das Anlegen
Try
Dim objParent As New DirectoryEntry("LDAP://" & ouString & "dc=dasAD, dc=int,_
", strADUser & "@dasAD.int", strADPasswort, AuthenticationTypes.Secure)
Dim objChild As DirectoryEntry = objParent.Children.Add("cn=" & Username, "user")
objChild.Properties("sAMAccountName").Add(Username)
objChild.Properties("mail").Add(email)
objChild.CommitChanges()
objChild.Invoke("SetPassword", New Object() {Passwort})
objChild.NativeObject.AccountDisabled = False
objChild.CommitChanges()
objChild.Close()
Nun ist der User Angelegt. Nun fügen wir diesen Noch einer Gruppe hinzu.
Dim objGroup As New DirectoryEntry("LDAP://cn=testgruppe, ou=people, ou=Gruppen,_
dc=dasAD, dc=int", strADUser & "@hfwu.int", strADPasswort, AuthenticationTypes.Secure)
objGroup.Invoke("Add", New Object() {objChild.Path.ToString()})
Catch x As Exception
MsgBox(x.Message)
MsgBox("Programm wird beendet")
Exit Sub
End Try
Klappt Wunderbar bei mir und mehrere hundert User sind kein Problem. =)