With the exception of the creating a homedirectory this code works.
Can anyone give me the correct format for the
homedirectory value?
this one give me the correct userdata on the profile page in AD
Properties("homedirectory").Add("\\TestServer2\Home_Folders$\" & sUserName)
but the users folder is not created on the members server TestServer2.
What I have tried:
Public Sub CreateAdAccount(ByVal sUserName As String, ByVal sPassword As String, ByVal sFirstName As String, ByVal sLastName As String, ByVal sGroupName As String, ByVal Ou As String)
Try
Dim StrRoot As String = "LDAP://" & Ou & ""
Dim root As New DirectoryEntry(StrRoot)
Dim newUser As DirectoryEntry = root.Children.Add("CN=" & sUserName, "user")
SetProperty(newUser, "description", "Some Test")
SetProperty(newUser, "givenname", sFirstName)
SetProperty(newUser, "sn", sLastName)
SetProperty(newUser, "SAMAccountName", sUserName)
SetProperty(newUser, "DisplayName", Info.DisplayName)
SetProperty(newUser, "userPrincipalName", sUserName & "@TecGroup.org")
SetProperty(newUser, "mail", sUserName & "@TecGroup.org")
SetProperty(newUser, "homedrive", "H:")
newUser.CommitChanges()
newUser.Close()
root.Close()
SaveTextToFile(sUserName & " added to AD, password " & sPassword, AppLogPath)
Catch ExtendedErrorMessage As Exception
SaveTextToFile("Add User " & sUserName & " failed, Error " & ExtendedErrorMessage.Message, AppLogPath)
End Try
end sub