Click here to Skip to main content
15,897,371 members

VS Studio 2010 3.5 web service application issue

Scott C Hall asked:

Open original thread
I have a web service application that accepts soap calls to add/remove members to local groups on servers. The application works if called from a windows client but the application fails when called from a unix client. I am using impersonation on the .net with a service account that has full admin rights on the end clients we are trying to modify.

From the unix client it dies on the objLocalGroup = GetObject(WinNT:// line

I am assuming it is some sort of .net setting for authentication. If anyone has any ideas where i should look or better ideas how to write the function it would be appreciated.

I have a custom application pool running as the service account. The website application is configured to use the application pool id.

VB
  <WebMethod()> _
Function RemoveFromGroup(ByVal target_group As String,
                    ByVal domain As String,
                    ByVal account As String,
                    ByVal system As String) As Object
    '#############################
    'Function RemoveFromGroup
    'Variables
    'system Target server
    'domain of Group / User being added
    'account (Name of Group or User)
    'target_group group we are modifying membership
    'Returns
    'STATUS|domain:account|TIMESTAMP as a single string
    Dim AlreadyExists As Integer
    Dim action = "RemoveFromGroup"
    'Create an group object referencing the group on the target server
    objLocalGroup = GetObject("WinNT://" & system & "/" & target_group & ",group")
    If Err.Number = 0 Then
        'Check to see if the account already exists in the local Admin group
        For Each Group In objLocalGroup.Members
            If InStr(UCase(Group.ADSPath), UCase(domain & "/" & account)) <> 0 Then
                AlreadyExists = True
            End If
        Next
        'Add the specified account to the local target group if it doesn't already exist
        If AlreadyExists = True Then
            objLocalGroup.Remove("WinNT://" & domain & "/" & account)
            If Err.Number = 0 Then
                RemoveAccountFromLocalGroup = 0
            Else
                RemoveAccountFromLocalGroup = 1
                Err.Clear()
            End If
        Else
            RemoveAccountFromLocalGroup = 2
        End If
    Else
        RemoveAccountFromLocalGroup = 3
        retmsg = "FAILED-cannot connect to server|" & action & "|" & domain & ":" & account & "|" & Date.Now & "|group-" & target_group
        Err.Clear()
    End If
    If RemoveAccountFromLocalGroup = 0 Then
        retmsg = "SUCCESS|" & action & "|" & domain & ":" & account & "|" & Date.Now & "|group-" & target_group
    ElseIf RemoveAccountFromLocalGroup = 1 Then
        retmsg = "FAILED|" & action & "|" & domain & ":" & account & "|" & Date.Now & "|group-" & target_group
    ElseIf RemoveAccountFromLocalGroup = 2 Then
        retmsg = "SUCCESS-NA|" & action & "|" & domain & ":" & account & "|" & Date.Now & "|group-" & target_group
    End If
    'clear variables to prevent memory leaks
    strDomainUser = Nothing
    objDomainUser = Nothing
    objLocalGroup = Nothing
    AlreadyExists = Nothing
    RemoveAccountFromLocalGroup = Nothing
    action = Nothing
    Return retmsg
End Function
Tags: .NET, IIS 6.0, IIS, SOAP

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900