public static unsafe int GetPrincipalNameImpl(PrincipalHandle handle,
                                                      /*[out]*/ char *outName, int outNameLength)
        {
            Principal p    = PrincipalImpl.MakePrincipal(handle.val);
            string    name = p.GetName();

            if (name.Length > outNameLength)
            {
                return(-name.Length);
            }
            return(name.InternalGetChars(outName, outNameLength));
        }
Esempio n. 2
0
        public static PrincipalHandle TransferPrincipal(PrincipalHandle oldH,
                                                        int processId,
                                                        ref DelegationState delegationState)
        {
            Process p = Process.GetProcessByID(processId);

            if (p == null)
            {
                throw new ApplicationException("Delegate endpoint process is null");
            }

            DelegationState newstate;
            Principal       pr;

            switch (delegationState)
            {
            case DelegationState.ByMediation:
                pr = PrincipalImpl.NewDelegation(
                    PrincipalImpl.MakePrincipal(oldH.val), p.Principal);
                newstate = DelegationState.Mediated;
                break;

            case DelegationState.ByCapability:
                pr = PrincipalImpl.NewDelegation(
                    PrincipalImpl.MakePrincipal(oldH.val), p.Principal);
                newstate = DelegationState.None;
                break;

            case DelegationState.Mediated:
                pr       = p.Principal;
                newstate = DelegationState.None;
                break;

            case DelegationState.None:
            default:
                pr       = p.Principal;
                newstate = DelegationState.None;
                break;
            }

            delegationState = newstate;
            return(new PrincipalHandle(pr.Val));
        }