kinit ratner@DO.CO; \
ldapsearch -Y GSSAPI -LLL -b dc=do,dc=co -H ldap://do.co '(SamAccountName=Ratner)' msDS-KeyVersionNumber
$user=ratner
Ратнер Арсений, arsenyratner@gmail.com, 7 985 273 2090
$Source = @" [DllImport("BluetoothAPIs.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall)] [return: MarshalAs(UnmanagedType.U4)] static extern UInt32 BluetoothRemoveDevice(IntPtr pAddress); public static UInt32 Unpair(UInt64 BTAddress) { GCHandle pinnedAddr = GCHandle.Alloc(BTAddress, GCHandleType.Pinned); IntPtr pAddress = pinnedAddr.AddrOfPinnedObject(); UInt32 result = BluetoothRemoveDevice(pAddress); pinnedAddr.Free(); return result; } "@ Function Get-BTDevice { Get-PnpDevice -class Bluetooth | ?{$_.HardwareID -match 'DEV_'} | select Status, Class, FriendlyName, HardwareID, # Extract device address from HardwareID @{N='Address';E={[uInt64]('0x{0}' -f $_.HardwareID[0].Substring(12))}} } ################## Execution Begins Here ################ $BTR = Add-Type -MemberDefinition $Source -Name "BTRemover" -Namespace "BStuff" -PassThru $BTDevices = @(Get-BTDevice) # Force array if null or single item Do { If ($BTDevices.Count) { "`n******** Bluetooth Devices ********`n" | Write-Host For ($i=0; $i -lt $BTDevices.Count; $i++) { ('{0,5} - {1}' -f ($i+1), $BTDevices[$i].FriendlyName) | Write-Host } $selected = Read-Host "`nSelect a device to remove (0 to Exit)" If ([int]$selected -in 1..$BTDevices.Count) { 'Removing device: {0}' -f $BTDevices[$Selected-1].FriendlyName | Write-Host $Result = $BTR::Unpair($BTDevices[$Selected-1].Address) If (!$Result) {"Device removed successfully." | Write-Host} Else {"Sorry, an error occured." | Write-Host} } } Else { "`n********* No devices found ********" | Write-Host } } While (($BTDevices = @(Get-BTDevice)) -and [int]$selected)powershell Convert-WindowsDHCPToKea.ps1 \ -in_xml "/var/tmp/win_dhcp.xml" \ -in_template "/etc/kea/kea-dhcp4.conf" \ -out_confdir "/etc/kea" \ -split "all" \ -out_dhcp4_conf "/etc/kea/kea-dhcp4.conf.json" \ -out_confd "/etc/kea/conf.d"
To do this we select all the users ((objectClass=user)) and all the people ((objectClass=person)) of the LDAP:
(&(objectCategory=person)(objectClass=user)) To do this we select all the users ((objectClass=user)) having a Service Principal Name (SPN) defined ((servicePrincipalName=*)) and we remove from our results:
krbtgt (which by definition has an SPN) with the filter (!(cn=krbtgt)).(!(userAccountControl:1.2.840.113556.1.4.803:=2)))Which gives us:
(&(objectClass=user)(servicePrincipalName=*)(!(cn=krbtgt))(!(userAccountControl:1.2.840.113556.1.4.803:=2))) To do this we select all the users ((objectClass=user)) that have "Do not require Kerberos preauthentication" flag set in their userAccountControl:
(&(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=4194304)) (&(objectCategory=user)(pwdLastSet=0)) (&(objectCategory=user)(badPwdCount>=4)) (&(objectCategory=user)(|(description=*pass*)(description=*pwd*))) The adminCount attribute specifies that a given object has had its access control lists (ACLs) changed to a more secure value by the Active Directory system because it is a member of one of the administrative groups, either directly or transitively.
(&(objectCategory=user)(adminCount=1)) (objectCategory=group) The adminCount attribute specifies that a given object has had its access control lists (ACLs) changed to a more secure value by the Active Directory system because it is a member of one of the administrative groups, either directly or transitively.
(&(objectCategory=group)(adminCount=1)) (servicePrincipalName=*) To list specific services, we can use the beginning of the servicePrincipalName attribute:
(servicePrincipalName=http/*) Here is a few examples of servicePrincipalName:
ldap/DC01.LAB.localkadmin/changepw (of kerberos service CN=krbtgt,CN=Users,DC=LAB,DC=local)MSSQLSvc/DC01.LAB.localFor example to list all the machines under Windows XP:
(&(objectCategory=Computer)(operatingSystem=Windows XP*)) With operatingSystem in:
Windows Server 2022*Windows Server 2019*Windows Server 2016*Windows Server 2008*Windows 11*Windows 10*Windows 8*Windows 7*Windows Vista*Windows XP*Windows Server 2003*Windows 2000*(sAMAccountType=805306369) This is useful to check for shadow credentials on machine accounts:
(&(objectClass=computer)(msDS-KeyCredentialLink=*)) (&(objectCategory=Computer)(|(operatingSystem=Windows 2000*)(operatingSystem=Windows Vista*)(operatingSystem=W