Hello,

I've developed an application to create NDS and GroupWise users. The
documentation indicates that I can use either the system, domain or
postoffice objects to create a user by calling the Users.Add method on one
of theses objects. I've tried them all and the only account being created is
the NDS account. The GroupWise account is not created and an exception is
thrown on User.Add(). The exception is "Could not create the user in
edirectory."

I appreciate some insight into the error.

Here is some sample code.

Thanks
Tim

Private Sub CreateUser(ByVal fieldValues As List(Of String), ByVal
definedValues As List(Of String))

If Not (Me.Fields.Contains("Domain")) Then

Throw New Exception("Domain name required")

End If

Dim domainName As String = fieldValues(Me.Fields.IndexOf("Domain"))

If Not (Me.Fields.Contains("PostOffice")) Then

Throw New Exception("PostOffice name required")

End If

Dim poName As String = fieldValues(Me.Fields.IndexOf("PostOffice"))

If Not (Me.Fields.Contains("Surname")) Then

Throw New Exception("Surname required")

End If

Dim surName As String = fieldValues(Me.Fields.IndexOf("Surname"))

If Not (Me.Fields.Contains("DistinguishedName")) Then

Throw New Exception("DistinguishedName required")

End If

Dim distinguishedName As String =
fieldValues(Me.Fields.IndexOf("DistinguishedName") )

' update log file

'

GWLog.Instance.Log("GWCreate.CreateUser({0})", distinguishedName)

' get username

'

Dim userName As String = distinguishedName.Split(New String() {"."},
StringSplitOptions.RemoveEmptyEntries).FirstOrDefa ult()

' get domain

'

Dim domain As GWLibrary.Domain = m_system.Domains.Item(domainName)

' get postoffice

'

'Dim po As GWLibrary.PostOffice = domain.PostOffices.Item(poName)

Dim po As GWLibrary.PostOffice = m_system.PostOffices.Item(poName, domain)

' create new user

'

'Dim newUser As GWLibrary.User = po.Users.Add(userName, surName,
distinguishedName, "password")

Dim newUser As GWLibrary.User = m_system.Users.Add(userName, surName,
distinguishedName, String.Empty, po, domain)

' cast to User3 type

'

Dim user As GWLibrary.User3 = CType(newUser, GWLibrary.User3)

' process field definedValues

'

With user

For Each field As String In fieldValues

Select Case (field)

Case "AccountID"

..AccountID = fieldValues(Me.Fields.IndexOf(field))

Case "Department"

..Department = fieldValues(Me.Fields.IndexOf(field))

Case "Description"

..Description = fieldValues(Me.Fields.IndexOf(field))

Case "Name"

..Name = fieldValues(Me.Fields.IndexOf(field))

Case "FaxNumber"

..FaxNumber = fieldValues(Me.Fields.IndexOf(field))

Case "GivenName"

..GivenName = fieldValues(Me.Fields.IndexOf(field))

Case "NetID"

..NetID = fieldValues(Me.Fields.IndexOf(field))

Case "PhoneNumber"

..PhoneNumber = fieldValues(Me.Fields.IndexOf(field))

Case "PrefEMailID"

..PrefEMailID = fieldValues(Me.Fields.IndexOf(field))

Case "Surname"

..Surname = fieldValues(Me.Fields.IndexOf(field))

Case "Title"

..Title = fieldValues(Me.Fields.IndexOf(field))

Case "Visibility"

..Visibility =
Me.GetVisibility(CType([Enum].Parse(GetType(SageSoftSolutions.GroupWise.Busines s.Visibility),
fieldValues(Me.Fields.IndexOf(field))),
SageSoftSolutions.GroupWise.Business.Visibility))

End Select

Next

' commit field assignments

'

..Commit()

' process admin defined fieldValues

'

For Each defined As String In Me.Defined

Try

Dim field As GWLibrary.Field = .AdminDefined.Item(defined)

With field

..Value = fieldValues(Me.Defined.IndexOf(defined))

..Commit()

End With

Catch ex As Exception

GWLog.Instance.Log("GWCreate.CreateUser(Exception: ={0}, DefinedField:={1})",
ex.Message, defined)

End Try

Next

' commit defined field assignments

'

..Commit()

End With

End Sub