By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,101 Members | 1,359 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,101 IT Pros & Developers. It's quick & easy.

Help with IIS please

coderthebarbarian
P: 1
Using VB 2005. I've got to be able to connect to a server app in both a domain and a workgroup scenario using IIS. The domain code passes Windows Authentication. The workgroup code requires the user to enter their username and password. Checking "local impersonation" in the ASP.NET Configuration Settings lets the code for domain access to work, but not the workgroup. Unchecking "local impersonation" breaks the domain code. Anybody have code for both. Thanks.

Here's the two functions:
'domain
Public Function GetUsersGroups(ByVal ServerName As String, ByVal DomainName As String, ByVal UserName As String) As String()
Dim iCount As Integer = 0
Dim szGroups() As String = Nothing
Dim Computer
Dim oGroup
Dim Group
Dim groupnames As String = ""
Dim filter As System.Object() = {"group"}
Computer = GetObject("WinNT://" & ServerName)
Computer.Filter = filter
For Each Group In Computer
oGroup = GetObject("WinNT://" & ServerName & "/" & Group.name & ",group")
If oGroup.IsMember(GetObject("WinNT://" & DomainName & "/" & UserName & ",user").adspath) Then
ReDim Preserve szGroups(iCount)
szGroups(iCount) = Group.name
iCount += 1
End If
Next
Return szGroups
End Function

'workgroup
Public Function AuthenticateLogin(ByVal Workgroup As String, ByVal username As String, ByVal password As String) As Boolean
Try
Dim objNS = GetObject("WinNT:")
Dim filter As System.Object() = {"groups"}
Dim objContainer = objNS.OpenDSObject("WinNT://" & Workgroup, username, password, 1)
objContainer.filter = filter
For Each objUser As Object In objContainer

'Console.WriteLine(objUser.name)

Next
Return True
Catch Err As Exception
Return False
End Try
End Function
Mar 28 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.