<#
SYNOPSIS
This scripts provisions a new service claim identity as discussed in previous post.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $True, HelpMessage="the claim value to use")]
[string]$claimType, # example: "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn"
[Parameter(Mandatory = $True, HelpMessage="the claim value to use")]
[string]$claimValue,
[Parameter(Mandatory = $True, HelpMessage="The service identity name")]
[string]$sciName, # example: "dmsi-wus3-prod01-srs1"
[Parameter(Mandatory = $True, HelpMessage="The service tree identifier")]
[string]$serviceTreeId,
[Parameter(Mandatory = $True, HelpMessage="The subscription identifier")]
[string]$subscriptionId,
[Parameter(Mandatory = $True, HelpMessage="The custom instance")]
[string]$customInstance,
[Parameter(Mandatory = $True, HelpMessage="The service account")]
[string]$serviceAccount,
[Parameter(Mandatory = $True, HelpMessage="The region")]
[string]$region,
[Parameter(Mandatory = $False, HelpMessage="If the claim is scoped.")]
[string]$isScoped = $False,
[Parameter(Mandatory = $False, HelpMessage="The azure environment/cloud name")]
[string]$environmentName = "prod"
)
Ipmo \\location\client.dll
Connect-ProviderActiveClient Prod
$request = New-ProviderCreateManagedServiceClientIdentity
$request.Name = $sciName
$request.ServiceTreeId = $serviceTreeId
$request.CustomInstance = $customInstance
$request.ClaimProvisionings = @()
$claim = New-ProviderClaimProvisioning
$claim.ClaimInstance.Type = $claimType
$claim.ClaimInstance.Value = $claimValue
$claim.ScopedToServiceAccount = $serviceAccount
$claim.IsUnscoped= $isScoped
$request.ClaimProvisionings.Add($claim)
$request.Region = $region
$request.Subscriptions = @()
$request.Subscriptions.Add($subscriptionId)
$request | Add-ProviderManagedServiceClientIdentity
#codingexercise:
Q: An array A of N elements has each element within the range 0 to N-1. Find the smallest element P such that every value that occurs in A also occurs in sequence A[0], A[1] ... A[P]
For example, A = [2,2,1,0,1] and the smallest value of P is 3 where elements 2,2,1,0 contain all values that occur in A.
A:
public int getPrefix(int[] A) {
Int prefix = Integer.MIN_VALUE;
Int n = A.length;
Int visited = new int[n];
for (int i = 0; i < n; i++) {
if (visited[A[I]] == 0){
visited[A[I]] = 1;
Prefix = I;
}
}
return prefix;
No comments:
Post a Comment