I am trying to connect to a domain using the NetJoinDomain API. I can successfull use it to change the workgroup. But when trying to change the domain I get one of two errors, using the same input. I either get "No such domain" or "No mapping for the Unicode character exists in the target multi-byte code page." This is using the same exact inputs, I have hard coded the inputs in for debuging purposes.
What am I doing wrong?
Also for some reason I have to convert the strings into char arrays and insert a null value between each character. Anybody know why?
visual basic code:
Private Declare Function NetJoinDomain _
Lib "NETAPI32.dll" (ByVal lpServer As String, _
ByVal lpDomain As String, ByVal lpAccountOU As String, _
ByVal lpAccount As String, ByVal lpPassword As String, _
ByVal fJoinOptions As Int32) As Int32Public Sub ChangeDomain()
Private Sub ChangeDomain()
Dim d() As Char
Dim u() As Char
Dim p() As Char
' I replaced what the actual values are, since they were my username and password to the company domain
'InsertNulls is a function that I created to convert the strings to char arrays and insert null chars between each value
d = insertNulls("myDomain")
u = insertNulls("myUserName")
p = insertNulls("MyPassword")
err = NetJoinDomain("", d, "", u, p, JoinOptions.NETSETUP_DOMAIN_JOIN_IF_JOINED Or JoinOptions.NETSETUP_JOIN_DOMAIN)
End Sub