I am looking to join a LFDS user to a LFDS group. I have the LMO documentation. It has no examples of this. I looked through the API, but when I try it out, I get errors such as Value cannot be null or other such errors. I was able to create the user, get the group, but cannot seem to join the two.
The code that I use to create the user is as follows.
' Login to the Directory Server. Dim server As Laserfiche.LicenseManager.LMO.Server = Laserfiche.LicenseManager.LMO.Server.Connect(sDirectoryServerHostName, False) Dim db As Database = server.GetDatabaseByRealmName(sLicensingSiteName) db.LoginWindows() ' Is the user already created? Dim LFDSUser As LaserficheUser = LaserficheUser.Create(db) ' Need to create the user. LFDSUser.ContainerID = GetOrganizationbyName(sOrganizationName, db) LFDSUser.MfaRequired = False LFDSUser.Name = sUsername LFDSUser.Password = sPassword LFDSUser.Enabled = True
I created a supporter function, Get Group as I do not have the SID or ID of the group to use the Database.GetGroup() function. The supporter function is as follows.
Function GetGroup(sGroupName As String, db As Database, sOrganizationName As String) As Group Dim retval As Group = Nothing Try Dim nContainerID As Integer = GetOrganizationbyName(sOrganizationName, db) Dim groups As List(Of Group) = db.GetGroupsByContainer(nContainerID) For Each oGroup As Group In groups If oGroup.Name = sGroupName Then retval = oGroup Exit For End If Next Catch ex As Exception End Try Return retval End Function
I did that because I see that the Group object has a GetMembers() function and SetMembers() method.
After that I tried the GetMembers() function and was able to get the members with the following code:
Dim group As Group = GetGroup("Test", db, sOrganizationName) Dim members As Dictionary(Of String, String) = group.GetMembers() For each member As Object In members MsgBox( member.ToString() ) Next
This resulted in the result [sid, name]
Next I tried to add a member to the members list using:
members.Add(LFDSUser.SIDString, LFDSUser.Name)
This resulted in the error message Value cannot be null. Parameter name: key.