I am trying to get NetWare and ASP.Net...
Articles and Tips: qna
01 Mar 2003
Q.
I am trying to get NetWare and ASP.Net working with VB.Net code behind. I have been able to get a user authenticated and for NetWare to give that user's full name. What I need to do now is check if this user is a member of a certain NetWare group. Any ideas?
Current membership code I have is:
Private Function Is_MemberOfGrp(ByVal strGrpNameToChk As String, ByVal strUserToChkAgainst As String) As Boolean
Dim blnAnswer As Boolean = False Dim strErrMsg As String = ""
Try Dim saMembers As System.Array Dim dblCounter As Double = 0
'1] Find Group
objUser = objNWDir.FindEntry(strGrpNameToChk) Dim strUserName = objUser.GetFieldValue("Given Name", "No Value") + " " + objUser.GetFieldValue("SurName", "No Value") dblCounter = objUser.Entries.Count
'2] Get its list of members
saMembers = objUser.GetFieldValue("Member", "NotFound", True)
'3] Loop thru Member list
For dblCounter = LBound(saMembers) To UBound(saMembers) If (saMembers(dblCounter) = strUserToChkAgainst) Then blnAnswer = True Else blnAnswer = False End If
Next dblCounter
Catch strErrMsg = CStr(Err.Number) + ": " + Err.Description End Try
end_func: Is_MemberOfGrp = blnAnswer
End Function
A.
The group object doesn't have a given name or a surname. So I'm not clear on whether you have the user and wish to read the group membership, or if you have the group and wish to read the member list.
Your question indicates you already have a user, so it's easiest to read the group membership property of the user that you have.
objUser = AxNWDir1.Entries.Item(strUser)
and once you have the user, call
saMembers = objUser.GetFieldValue("Group Membership", "NotFound", True)
so you get a list of the full names of the groups to which that the user belongs. This is easier than searching for groups and reading the members.
* Originally published in Novell AppNotes
Disclaimer
The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.