Dim u As New UserPrincipal(SharedObjects.PrincipalContext)
u.Surname = ln
u.SamAccountName = login
u.EmailAddress = email
u.Name = ln
u.DisplayName = fn & " " & ln
u.Enabled = True
Dim context As PrincipalContext = New PrincipalContext(ContextType.Domain, SharedObjects.LDAPName(), "OU=Users,OU=" & My.Settings.OUName & "," & SharedObjects.LDAP_DomainName(), SharedObjects.UserLogin(), SharedObjects.UserPassword())
u.Save(context)
'THIS IS THE TRICK! Dim de As DirectoryEntry
de = DirectCast(u.GetUnderlyingObject(), DirectoryEntry)
de.Properties("Company").Value = entity
de.CommitChanges()
|