Skip to main content

API vs GUI - add/remove from group

Comments

6 comments

  • Official comment
    Permanently deleted user
    Development

    Hello Artur,

    It looks like you've found a bug in the PowerShell example code:

    Both instances of this line are incorrect:

    {
    $existingUser.$propName = @{priority = "user"; prioritySpecified = $true}
    }

    Instead, they should read:

    {
    $existingUser.$propName.priority = "user";
    $existingUser.$propName.prioritySpecified = $true
    }

    The previous code was incorrectly "blanking out" the 'value' of these properties.

    We will get the documentation updated as soon as possible.

    Thanks for bringing this to our attention!

  • Jeff Scott
    Product Support

    Hello Arthur,

     

    Could you please provide us with a snippet of the code you are using when removing the users from a group?  We are currently running some tests to see if there is something missing.

    0
  • Artur Sobczyk
    $newTestUserName = "xxx"
    $newTestGroupName = "yyy"

    [CerberusFtp.GetUserInformationRequest] $userInfoRequest = $requestWithCreds
    $userInfoRequest.userName = $newTestUserName

    [CerberusFtp.GetUserInformationResponse] $existingUserResponse = $CerberusSvc.GetUserInformation($userInfoRequest)

    if (-not $existingUserResponse.result){
    Write-Error "Failed to find user $newTestUserName : $($existingUserResponse.message)"
    } else {
    Write-Host "Successfully found $newTestUserName"

    $existingUser = $existingUserResponse.UserInformation

    $existingUser.groupList = @(@{name=$newTestGroupName})

    foreach ($propName in @( "authMethod"
    "disableAfterTime"
    "ipAllowedList"
    "isAllowPasswordChange"
    "isAnonymous"
    "isDisabled"
    "isSimpleDirectoryMode"
    "maxLoginsAllowed"
    "maxUploadFilesize"
    "protocols"
    "requireSecureControl"
    "requireSecureData")
    ) {
    $existingUser.$propName = @{priority = "group"; prioritySpecified = $true}
    }

    [CerberusFtp.AddUserRequest] $modifyUserRequest = $requestWithCreds
    $modifyUserRequest.User = $existingUser

    [CerberusFtp.AddUserResponse] $modifyUserResponse = $CerberusSvc.AddUser($modifyUserRequest)

    if (-not $modifyUserResponse.result){
    Write-Error "Failed to update exiting user: $($modifyUserResposne.message)"
    } else {
    Write-Host "Successfully made $newTestUserName a member of $newTestGroupName"
    }
    }

    # remove from group
    [CerberusFtp.GetUserInformationRequest] $getUserRequest = $requestWithCreds
    $getUserRequest.userName = $newTestUserName

    [CerberusFtp.GetUserInformationResponse] $getUserResponse = $CerberusSvc.GetUserInformation($getUserRequest)

    if (-not $getUserResponse.result){
    Write-Error "Failed to retrieve user: $(getUserResponse.message)"
    } else {
    Write-Host "Successfuly retrieved $($getUserResponse.UserInformation.name)"

    $existingUser = $getUserResponse.UserInformation

    if ($existingUser.groupList.Count -lt 1){
    Write-Error "Cannot remove user from group; user is not a member of any group"
    } else {
    $previousMembership = $existingUser.groupList
    $existingUser.groupList = @()

    foreach ($propName in @( "authMethod"
    "disableAfterTime"
    "ipAllowedList"
    "isAllowPasswordChange"
    "isAnonymous"
    "isDisabled"
    "isSimpleDirectoryMode"
    "maxLoginsAllowed"
    "maxUploadFilesize"
    "protocols"
    "requireSecureControl"
    "requireSecureData")
    ) {
    $existingUser.$propName = @{priority = "user"; prioritySpecified = $true}
    }

    [CerberusFtp.AddUserRequest] $modifyUserRequest = $requestWithCreds
    $modifyUserRequest.User = $existingUser

    [CerberusFtp.AddUserResponse] $modifyUserResponse = $CerberusSvc.AddUser($modifyUserRequest)

    if (-not $modifyUserResponse.result){
    Write-Error "Failed to update exiting user: $($modifyUserResponse.message)"
    } else {
    Write-Host "Successfully removed $newTestUserName from $($previousMembership.name -join ', ')"
    }
    }
    }
    0
  • Artur Sobczyk

    user "xxx" pre-exists

    with no primary or secondary group

    password never expires - yes

    user can change password - yes

    disabled - no

    max logons - unlimited

    allowed protocols - only https

     

    group "yyy" prexists

    members 0

    user can change password - yes

    disabled - yes

    max logons - unlimited

    protocols - only https

     

    0
  • Jeff Scott
    Product Support

    Thanks, Artur.  Our development team is reviewing this information, and we will provide an update as soon as we can.  We appreciate your patience.

    0
  • Artur Sobczyk

    Yes, that works!

    Thank you for fast response.

    0

Please sign in to leave a comment.