Security Credential Keyring

Author Message
turranx

  • Total Posts : 59
  • Scores: 0
  • Reward points : 0
  • Joined: 2/7/2006
  • Location: Cincinnati, OH
  • Status: offline
Security Credential Keyring Monday, October 25, 2010 7:56 AM (permalink)
0
I've been doing a lot of work inside Active Directory lately.  The company that picked me up has numerous AD Domain trusts.  To organize the collection of AD security credentials needed to perform audits on AD objects that are in different domains within the same script I created this security keyring.  It's not perfect, but I good solid step in the right direction.
 
The first step is to call the 'AddKey' method.  It will do the following:
  1. Prompt you for security credentials (user name and password) and store the credential object
  2. Connect to the domain you specified when calling 'AddKey' and store the connection object
 
How to access individual parameters:
$KeyRing.AddKey("abc.domain.com")
$KeyRing.Get_Item("abc.domain.com").Connection
$KeyRing.Get_Item("abc.domain.com").Credentials
How to use:
$KeyRing.AddKey("abc.domain.com")
$user = Get-QADObject -Connection ($KeyRing.GetItem("abc.domain.com").Connection) -Identity "Joe User"
 

To See all the entries:
$KeyRing
 
  # Initialize a Security Keyring 
$sscc = [system.stringcomparer]::CurrentCultureIgnoreCase;
$Keyring = New-Object System.Collections.Hashtable $sscc;
$Keyring = add-member -inputobject $Keyring `
     -membertype ScriptMethod `
     -name AddKey `
     -value {
      Param([string]$KeyName)
      
      if ($this.Contains("$KeyName")) { return; }
      
      $this.add("$KeyName",(New-Object PSObject));
      
       
      # CREATE the Domain Name Object
      $this.Set_Item("$KeyName", (Add-Member `
       -Name "Domain_Name" `
       -InputObject ($this.Get_Item("$KeyName")) `
       -PassThru `
       -MemberType NoteProperty `
       -Value $KeyName));
      
      # CREATE the Credentials Object
      $this.Set_Item("$KeyName", (Add-Member `
       -Name "Credentials" `
       -InputObject ($this.Get_Item("$KeyName")) `
       -PassThru `
       -MemberType NoteProperty `
       -Value (New-Object PSObject)));
      
      # POPULATE the Credentials Object
      $this.Get_Item("$KeyName").Credentials = $Host.UI.PromptForCredential("Need Credentials", `
         "Please enter your user name and password for '$KeyName'.", `
         "", `
         "NetBiosUserName");
      
      # CREATE the Connection Object
      $this.Set_Item("$KeyName", (Add-Member `
       -Name "Connection" `
       -InputObject ($this.Get_Item("$KeyName")) `
       -PassThru `
       -MemberType NoteProperty `
       -Value (New-Object PSObject)));
      
      # POPULATE the Connection Object
      try {
      $this.Get_Item("$KeyName").Connection = Connect-QADService `
                 -service $KeyName `
                 -Credential ($this.Get_Item("$KeyName").Credentials);
      }
      catch {
       $this.Get_Item("$KeyName").Connection = $_.Exception.toString();
      }
      
      # CREATE the Domain Identity Object
      if ($this.Get_Item("$KeyName").Connection.getType().Name -ine "string") {
       $this.Set_Item("$KeyName", (Add-Member `
        -Name "Users_Domain_Identity" `
        -InputObject ($this.Get_Item("$KeyName")) `
        -PassThru `
        -MemberType NoteProperty `
        -Value ($this.Get_Item("$KeyName").Credentials.UserName.ToString())));
      }
      else {
       $this.Set_Item("$KeyName", (Add-Member `
        -Name "Users_Domain_Identity" `
        -InputObject ($this.Get_Item("$KeyName")) `
        -PassThru `
        -MemberType NoteProperty `
        -Value "N/A"));
      }
      } `
     -passthru; 

Microsoft Windows 2000 Scripting Guide - The best book for newbie scripters
http://www.myspace.com/Evil__Overlord
 
#1
    anytua34i

    • Total Posts : 9
    • Scores: 0
    • Reward points : 0
    • Joined: 1/24/2011
    • Status: offline
    Re:Security Credential Keyring Monday, January 24, 2011 7:06 PM (permalink)
    0
    stress 8 relievers are ways new york asian escort that people have used as new york asian escorts stress management techniques. The stress balls are small round balls filled with beads or other squeezable material that you can squeeze. The method may sound new york escort silly but many people new york escorts swear by these stress relievers because the squeezing motion affects not only your hand
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9