Git Product home page Git Product logo

Comments (7)

hnrkndrssn avatar hnrkndrssn commented on September 20, 2024

@chrisgelhaus thanks for the report, I will test this out and get a fix put in for it.

from library.

hnrkndrssn avatar hnrkndrssn commented on September 20, 2024

Hey @chrisgelhaus

In your step template, could you try replacing

$isInGroup = ($members | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $, $null)}) -contains "$($user.Name)"

with this code snippet instead

    $allmembers = @()
    $isInGroup = ($members | foreach {
        $AdsPath = $_.GetType().InvokeMember("Adspath", "GetProperty", $null, $_, $null)
        # Domain members will have an ADSPath like WinNT://<DOMAINNAME>/<USERNAME>
        # Local members will have an ADSPath like WinNT://<DOMAINNAME>/<COMPUTERNAME>/<USERNAME>
        $a = $AdsPath.split('/', [StringSplitOptions]::RemoveEmptyEntries)
        $name = $a[-1]
        $domain = $a[-2]

        # determine if member is a 'user' or 'group' object
        $class = $_.GetType().InvokeMember("Class", "GetProperty", $null, $_, $null)

        $allmembers += New-Object PSObject -Property @{ 
            Name = $name;
            Domain = $domain;
            Class = $class;
            ComputerName = $ComputerName;
            GroupName = $GroupName;
        }
        return $allmembers
    }) -contains "$($user.Name)"

from library.

chrisgelhaus avatar chrisgelhaus commented on September 20, 2024

I'll try it when I can. I don't know if I mentioned this but my intent is to use this step to add a windows IIS virtual account like "IIS APPPOOL\accountname" to a local security group.

Sent from Outlook Mobile

On Thu, Dec 3, 2015 at 4:15 PM -0800, "Henrik Andersson" [email protected] wrote:

Hey @chrisgelhaus

In your step template, could you try replacing

$isInGroup = ($members | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $, $null)}) -contains "$($user.Name)"

with this code snippet instead

    $allmembers = @()
    $isInGroup = ($members | foreach {
        $AdsPath = $_.GetType().InvokeMember("Adspath", "GetProperty", $null, $_, $null)
        # Domain members will have an ADSPath like WinNT://<DOMAINNAME>/<USERNAME>
        # Local members will have an ADSPath like WinNT://<DOMAINNAME>/<COMPUTERNAME>/<USERNAME>
        $a = $AdsPath.split('/', [StringSplitOptions]::RemoveEmptyEntries)
        $name = $a[-1]
        $domain = $a[-2]

        # determine if member is a 'user' or 'group' object
        $class = $_.GetType().InvokeMember("Class", "GetProperty", $null, $_, $null)

        $allmembers += New-Object PSObject -Property @{
            Name = $name;
            Domain = $domain;
            Class = $class;
            ComputerName = $ComputerName;
            GroupName = $GroupName;
        }
        return $allmembers
    }) -contains "$($user.Name)"

Reply to this email directly or view it on GitHub:
#255 (comment)

from library.

chrisgelhaus avatar chrisgelhaus commented on September 20, 2024

It was unsuccessful. Below is the error from the step execution. I was able to fix this by using the response to this forum post. It looks like the issue may be directly related to the LENGTH of the username I'm using. Hope this helps.Cheers!

http://stackoverflow.com/questions/18208890/add-iis-apppool-asp-net-v4-0-to-local-windows-group

Windows - Add Users to Local Groups
UserNames: IIS AppPool\OneReallyLongSiteName
GroupNames: DB2USERS
IIS AppPool/OneReallyLongSiteName
IIS AppPool/OneReallyLongSiteName
System.DirectoryServices.DirectoryEntry
Error 11:34:37User IIS AppPool/OneReallyLongSiteName was not foundError 11:34:37At C:\Windows\system32\config\systemprofile\AppData\Local\Tentacle\Temp\63766caError 11:34:373-900e-4de3-a12c-0b506049754f.ps1:131 char:18Error 11:34:37+ throw <<<< "User "+ $userName +" was not found"Error 11:34:37 + CategoryInfo : OperationStopped: (User IIS AppPoo...e was not f Error 11:34:37 ound:String) [], RuntimeExceptionError 11:34:37 + FullyQualifiedErrorId : User IIS AppPool/OneReallyLongSiteName was not f Error 11:34:37 oundInfo 11:34:37ERROR - "WinNT://" not found
Info 11:34:37==============================================
PowerShell exit code: 1
==============================================Fatal 11:34:37PowerShell script returned a non-zero exit code: 1
Tentacle version 2.6.4.951
Date: Thu, 3 Dec 2015 16:15:33 -0800
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [Library] Step Template - Windows Add Users to Local Groups (#255)

Hey @chrisgelhaus

In your step template, could you try replacing

$isInGroup = ($members | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $, $null)}) -contains "$($user.Name)"

with this code snippet instead

$allmembers = @()
$isInGroup = ($members | foreach {
    $AdsPath = $_.GetType().InvokeMember("Adspath", "GetProperty", $null, $_, $null)
    # Domain members will have an ADSPath like WinNT://<DOMAINNAME>/<USERNAME>
    # Local members will have an ADSPath like WinNT://<DOMAINNAME>/<COMPUTERNAME>/<USERNAME>
    $a = $AdsPath.split('/', [StringSplitOptions]::RemoveEmptyEntries)
    $name = $a[-1]
    $domain = $a[-2]

    # determine if member is a 'user' or 'group' object
    $class = $_.GetType().InvokeMember("Class", "GetProperty", $null, $_, $null)

    $allmembers += New-Object PSObject -Property @{ 
        Name = $name;
        Domain = $domain;
        Class = $class;
        ComputerName = $ComputerName;
        GroupName = $GroupName;
    }
    return $allmembers
}) -contains "$($user.Name)"


Reply to this email directly or view it on GitHub.

from library.

hnrkndrssn avatar hnrkndrssn commented on September 20, 2024

@chrisgelhaus great to hear that you were able to get it working in the end!

Could you send through your step template so that we can update it in the library?

Thanks!

from library.

chrisgelhaus avatar chrisgelhaus commented on September 20, 2024

Hi Henrick,I apologize. I didn't update the library step template with those commands, I created my own step template using those commands. You have a better understanding of the step template than I do, so I didnt want to mess anything up. I can try to integrate them if you like, But I figured you'd be better at it than me!
Cheers!Chris
This is my entire step template:
$group = [ADSI]"WinNT://$Env:ComputerName/$localGroupName,group"$ntAccount = New-Object System.Security.Principal.NTAccount("$userAccount")$strSID = $ntAccount.Translate([System.Security.Principal.SecurityIdentifier])$user = [ADSI]"WinNT://$strSID"$group.Add($user.Path)

Date: Sun, 6 Dec 2015 16:08:05 -0800
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [Library] Step Template - Windows Add Users to Local Groups (#255)

@chrisgelhaus great to hear that you were able to get it working in the end!

Could you send through your step template so that we can update it in the library?

Thanks!


Reply to this email directly or view it on GitHub.

from library.

hnrkndrssn avatar hnrkndrssn commented on September 20, 2024

Thanks @chrisgelhaus I'll rework the current step template in the Library 👍

from library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.