Announcement

Collapse
No announcement yet.

Taskpad-View: 'Shell Command' gets the selected Object from the ADUC snap-in

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Taskpad-View: 'Shell Command' gets the selected Object from the ADUC snap-in

    Hi,

    I am new to AD and vbscripting. Trying to get the following done:

    I am working on a simple SnapIn for ADUC (Windows Desktop) and in one of the views I have a vbscript that sends an email to the person managing the group requesting for group membership. Problem is I have a input box and user have to type in the name by looking at hunderds of groups in a OU. Is there a way I can pass in the name of the selected group (group that user clicks on to select it) to my input box in the vbscript.

    Thanks in advance

  • #2
    Re: How to get a selected Group

    Moved to scripting forum

    Can you read the name of the selected group (e.g. from a drop down list) into a variable?
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: How to get a selected Group

      try this:
      Code:
      Set objGroup = GetObject _
        ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")
       
      Set objNtSecurityDescriptor = objGroup.Get("ntSecurityDescriptor")
       
      WScript.Echo "Owner Tab"
      WScript.Echo "Current owner of this item: " & objNtSecurityDescriptor.Owner
      It's clearly a fabrikam environment, and it came from here:
      http://www.activexperts.com/activmon...groups/groups/

      WScript.Echo "Current owner of this item: " & objNtSecurityDescriptor.Owner
      Please do show your appreciation to those who assist you by leaving Rep Point https://www.petri.com/forums/core/im.../icon_beer.gif

      Comment


      • #4
        Re: How to get a selected Group

        To get a group like this works fine:
        Set objGroup = GetObject _ (ldap://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com)

        What I am after is that if "Scientists" group abvoe in ADUC is currently selected by user. When I run vbscript can something return me the path "ldap://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com"

        Comment


        • #5
          Re: How to get a selected Group

          Originally posted by Ossian View Post
          Moved to scripting forum

          Can you read the name of the selected group (e.g. from a drop down list) into a variable?
          Hi Ossian,

          No I don't have a drop down list. Is there a way I can have a drop down list object in vbscript. That can also be one of the solutions to my problem.

          Comment


          • #6
            Re: How to get a selected Group

            You created a Taskpad View and have added a "shell command".

            To run the script specifically with the selected object (User, Goup or Computer)...

            You first have to add a column,
            - Click View and then click Add/Remove Columns.
            - Select 'Pre-Windows 2000 Logon Name', and click Add.

            Now you are able to pass this atribute (Pre-Windows 2000 Logon Name) as script argument.

            Edit the command line options,
            - Select "Edit the Taskpad view" and goto tab "Tasks"
            - Modify the shell command task.
            - At the tab "Command line", at "Script Parameters" add: "$COL<9>"
            (you can keep the parameter between quotes, that is fine)

            Finally you have to modify your script.
            Code:
            Set args = WScript.Arguments
            If args.count > 0 Then
               strNTName = args.Item(0)
               If (Trim(strNTName)) = "" Then wscript.quit
            Else
               wscript.quit
            End If

            I don't know your script, but here is an sample you can use for testing,
            Code:
            Set args = WScript.Arguments
            If args.count > 0 Then
               strNTName = args.Item(0)
               If (Trim(strNTName)) = "" Then wscript.quit
            Else
               wscript.quit
            End If
            
            ' Retrieve the NetBIOS name of the domain.
            With CreateObject("WScript.Network")
               strNetBIOSDomain = .UserDomain
            End With
            
            ' Translate NTName to the object's Distinguished Name.
            strAccountName = strNetBIOSDomain & "\" & strNTName
            With CreateObject("NameTranslate")
               .Init 3, "" : .Set 3, strAccountName
               strObjectDN = Replace(.Get(1), "/", "\/")
            End With
            
            ' Bind to the object in Active Directory with the LDAP provider.
            Set objItem = GetObject("LDAP://" & strObjectDN)
            
            ' i.e. Show the common name of the object
            wscript.echo objItem.cn

            \Rems

            This posting is provided "AS IS" with no warranties, and confers no rights.

            __________________

            ** Remember to give credit where credit's due **
            and leave Reputation Points for meaningful posts

            Comment


            • #7
              Re: How to get a selected Group

              Originally posted by Rems View Post
              You created a Taskpad View and have added a "shell command".

              To run the script specifically with the selected object (User, Goup or Computer)...

              You first have to add a column,
              - Click View and then click Add/Remove Columns.
              - Select 'Pre-Windows 2000 Logon Name', and click Add.

              Now you are able to pass this atribute (Pre-Windows 2000 Logon Name) as script argument.

              Edit the command line options,
              - Select "Edit the Taskpad view" and goto tab "Tasks"
              - Modify the shell command task.
              - At the tab "Command line", at "Script Parameters" add: "$COL<9>"
              (you can keep the parameter between quotes, that is fine)

              Finally you have to modify your script.
              Code:
              Set args = WScript.Arguments
              If args.count > 0 Then
                 strNTName = args.Item(0)
                 If (Trim(strNTName)) = "" Then wscript.quit
              Else
                 wscript.quit
              End If

              I don't know your script, but here is an sample you can use for testing,
              Code:
              Set args = WScript.Arguments
              If args.count > 0 Then
                strNTName = args.Item(0)
                If (Trim(strNTName)) = "" Then wscript.quit
              Else
                wscript.quit
              End If
               
              ' Retrieve the NetBIOS name of the domain.
              With CreateObject("WScript.Network")
                strNetBIOSDomain = .UserDomain
              End With
               
              ' Translate NTName to the object's Distinguished Name.
              strAccountName = strNetBIOSDomain & "\" & strNTName
              With CreateObject("NameTranslate")
                .Init 3, "" : .Set 3, strAccountName
                strObjectDN = Replace(.Get(1), "/", "\/")
              End With
               
              ' Bind to the object in Active Directory with the LDAP provider.
              Set objItem = GetObject("LDAP://" & strObjectDN)
               
              ' i.e. Show the common name of the object
              wscript.echo objItem.cn

              \Rems
              Rems,

              Perfect this works great and is exactly what I was looking for. I am sure a newbee like me won't know this.
              I am not sure how to give credit or reputation points. Let me know how to
              do it.

              Thanks
              Last edited by itsme; 30th November 2010, 06:48.

              Comment


              • #8
                Re: Taskpad-View: 'Shell Command' gets the selected Object from the ADUC snap-in

                Glad I was able to help.

                For anyone interested, there is this Petri article "Create Taskpads for Active Directory Operations".

                _
                Because the subject of this thread is primary about creating 'shell command'-tasks in a Taskpad view from the ADU&C snap-in, I therefore moved this thread back to AD forum. But will leave a permanent redirect here in the scripting forum. And I have changed the topic title to: Taskpad-View: 'Shell Command' gets the selected Object from the ADUC snap-in.
                _



                Using Command line Parameters with shell commands from within a Taskpad View is not at all documented by Microsoft and there is not so much information about it on the internet.
                While it could turn the taskpad-view into a powerful tool for delegating special tasks or, to create a customized AD-tool for domain admins i.e. to quickly retrieve additional account information (without need editing object's context menu in AD).

                The command line argument options available for a Task are limited (with few exceptions now and then) to the columns you can add and should have added in the view (if that column is not visible in the view then the script-task icon will not appear at all!).
                However IMHO there should have had been an option to select always the 'Distinguished Name' for the ADUC snap-in undepended what colums are or aren't made visible in the view, but unfortunately it is not.

                Because of the fact the Distinguished Name is not one of the parameters that you can select, you have to do use the acoountname and then create some additional steps in the script (batch or vbscript) in order you can bind to an Active Directory object.
                Firstly, you should hard code or, find a way to obtain the Netbiosname of the Domain.
                Secondly, when using the LDAP provider - you have to translate the NTaccountname to the Distinguished Name.

                That is what the sample vbscript is doing.
                (In a batch you can make use of DSQUERY piped to a DSGET statement).


                Additionally,
                In combination with 'HTA', it *is* possible to pop-up a dropdown lists from where you can to select a value.
                For example, in the task view select a user object -> run script for that account. The script can show i.e. a list of Groups the user is a member of, you select one group and the script can use it successively.



                \Rems

                This posting is provided "AS IS" with no warranties, and confers no rights.

                __________________

                ** Remember to give credit where credit's due **
                and leave Reputation Points for meaningful posts

                Comment

                Working...
                X