Sharepoint Answers

 
Home » Forum » Sharepoint       Ask a questionRSS Feeds
  Question Asked By: Oliver Nunez   on Nov 07, 2003 In Sharepoint Category.

 
Question Answered By: Gabriel Patterson   on Nov 07, 2003

Hope this may help


Private Function GetUserRoles(ByVal web As SPWeb, ByVal Username As String, ByRef sError As String, ByRef isadmin As Boolean) as ArrayList

' Retrive the list of Role for the server

Dim resultArray As New ArrayList



Dim myws As New WSS.UserGroup





myws.Url = web.Url.ToString + "/_vti_bin/UserGroup.asmx"

Dim sUsername As String

Dim sPassword, sEncPassword As String

Dim sDomain As String

Dim sPublicKey As String



Try

sUsername = System.Configuration.ConfigurationSettings.AppSettings("usrSiteGroups")

sPassword = System.Configuration.ConfigurationSettings.AppSettings("pwdSiteGroups")

sDomain = System.Configuration.ConfigurationSettings.AppSettings("domSiteGroups")





Catch ex As Exception

sError = "Error getting sitegroup username, please adjust"

Exit Function

End Try

If sUsername Is Nothing Then

sError = "Error getting sitegroup username, please adjust"

Exit Function

End If

Dim authorizedCredentials As New CredentialCache

Dim credentials As NetworkCredential = New NetworkCredential(sUsername, sPassword, sDomain)



' Add the NetworkCredential to the CredentialCache.



Dim sAuth As String = System.Configuration.ConfigurationSettings.AppSettings("auth")



If sAuth Is Nothing And sAuth = "" Then

sAuth = "NTLM"

End If

authorizedCredentials.Add(New Uri(myws.Url), sAuth, credentials)



' Add the CredentialCache to the proxy class credentials.

myws.Credentials = authorizedCredentials

Dim ndGroups As XmlNode = myws.GetRoleCollectionFromWeb()



Try

For i As Integer = 0 To ndGroups.ChildNodes(0).ChildNodes.Count - 1





' For each role list the users, scan thru the user



Dim onerole As XmlNode = ndGroups.ChildNodes(0).ChildNodes(i)



Dim RoleName As String = onerole.Attributes("Name").Value

myws.Credentials = authorizedCredentials



Dim ndUsers As XmlNode = myws.GetUserCollectionFromRole(RoleName)



For j As Integer = 0 To ndUsers.ChildNodes(0).ChildNodes.Count - 1



Dim oneuser As XmlNode = ndUsers.ChildNodes(0).ChildNodes(j)

Dim UserRoleName As String = oneuser.Attributes("LoginName").Value

If Username = UserRoleName Then

If RoleName = "Administrator" Then

isadmin = True

End If

resultArray.Add(RoleName)

Exit For

End If

Next

Next



Catch ex As SPException

Dim message As String = ex.message

Catch ex As Exception

Dim message As String = ex.message

Catch ex As System.Web.Services.Protocols.SoapException

Dim message As String = ex.message

End Try

Return resultArray

' For each role, retrieve list of user, if user in the role, add to the list



End Function

Tagged:              

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on .Net Passport and Sharepoint Portal Server 2003 Or get search suggestion and latest updates.