| 2 | |
| 3 | Aparte ejecuto este script porque el problema puede deberse a usuarios que se han creado con un schema de AD de 2003. Habría que subir cuando antes el nivel funcional. |
| 4 | |
| 5 | {{{#!powershell |
| 6 | # Description: This script will add missing permissions for the Terminal |
| 7 | #Server License Server group to user objects in Active Directory. |
| 8 | # This may solve problems with TS CALs not beeing issued and event id |
| 9 | #4105 being logged at the license server. |
| 10 | |
| 11 | # Constants |
| 12 | $URL = "LDAP://DC=uco,DC=es"; |
| 13 | |
| 14 | cls |
| 15 | $root = New-Object DirectoryServices.DirectoryEntry $URL |
| 16 | $ds = New-Object DirectoryServices.DirectorySearcher |
| 17 | $ds.PageSize = 2000 |
| 18 | $ds.SearchRoot = $root |
| 19 | $ds.filter = "objectCategory=Person" |
| 20 | $src = $ds.findall() |
| 21 | write-host "Found" $src.count "user objects.`n" |
| 22 | $src | %{ |
| 23 | $de = $_.getdirectoryentry() |
| 24 | $accessrules = $de.get_objectsecurity().getaccessrules($true, $false,[System.Security.Principal.SecurityIdentifier]) | ?{$_.ObjectType -eq "5805bc62-bdc9-4428-a5e2-856a0f4c185e"} |
| 25 | if ((measure-object -inputobject $accessrules).count -eq 0) |
| 26 | { |
| 27 | $ar = new-object System.DirectoryServices.ActiveDirectoryAccessRule([System.Security.Principal.SecurityIdentifier]"S-1-5-32-561", 48, "Allow", [guid]"5805bc62-bdc9-4428-a5e2-856a0f4c185e") |
| 28 | $de.get_objectsecurity().addaccessrule($ar) |
| 29 | $de.commitchanges() |
| 30 | write-host -f yellow ("Added:`t" + $de.properties["sAMAccountName"]) |
| 31 | start-sleep -m 200 |
| 32 | } |
| 33 | else |
| 34 | { |
| 35 | write-host -f green ("OK:`t" + $de.properties["sAMAccountName"]) |
| 36 | } |
| 37 | } |
| 38 | }}} |