B
Bob
I am having trouble getting some VB.Net code to add a
user to that AD. I'm getting a very odd error that I
can't seem to get rid of and the cause is not making
itself very clear. Not to mention the fact that finding
info on this error is rather tough.
The error I get when try to add the user is:
"An invalid dn syntax has been specified."
It says it is taking place on the line of code in which I
try to set the password for the new user.
Here is my code as it stands now:
Dim de As New DirectoryEntry
("LDAP://CN=Users,DC=thelancaircompany,DC=com", "tlc\admin
istrator", "Password", AuthenticationTypes.Encryption)
Dim user As DirectoryEntry = de.Children.Add
("testa", "user")
Dim pass As New Object()
pass = "NewPassword"
user.Properties("SAMAccountName").Value
= "testa"
user.Properties("userPrincipalName").Value
= "testa"
user.Properties("scriptpath").Value
= "start.bat"
user.Properties("givenname").Value = "test"
user.Properties("sn").Value = "test"
user.Properties("displayname").Value = "test
a. test"
user.Properties("department").Value
= "Accounting"
user.Properties("initials").Value = "A"
user.Properties("profilepath").Value
= "\\condor\files\users\profiles\testa" '& AD1.UserName
user.Invoke("SetPassword", pass)
user.CommitChanges()
Any help would be greatly appreciated.
TIA
user to that AD. I'm getting a very odd error that I
can't seem to get rid of and the cause is not making
itself very clear. Not to mention the fact that finding
info on this error is rather tough.
The error I get when try to add the user is:
"An invalid dn syntax has been specified."
It says it is taking place on the line of code in which I
try to set the password for the new user.
Here is my code as it stands now:
Dim de As New DirectoryEntry
("LDAP://CN=Users,DC=thelancaircompany,DC=com", "tlc\admin
istrator", "Password", AuthenticationTypes.Encryption)
Dim user As DirectoryEntry = de.Children.Add
("testa", "user")
Dim pass As New Object()
pass = "NewPassword"
user.Properties("SAMAccountName").Value
= "testa"
user.Properties("userPrincipalName").Value
= "testa"
user.Properties("scriptpath").Value
= "start.bat"
user.Properties("givenname").Value = "test"
user.Properties("sn").Value = "test"
user.Properties("displayname").Value = "test
a. test"
user.Properties("department").Value
= "Accounting"
user.Properties("initials").Value = "A"
user.Properties("profilepath").Value
= "\\condor\files\users\profiles\testa" '& AD1.UserName
user.Invoke("SetPassword", pass)
user.CommitChanges()
Any help would be greatly appreciated.
TIA