コード例 #1
0
 public static extern uint RpcBindingSetAuthInfo(
     IntPtr Binding,
     string ServerPrincName,
     RPC_C_AUTHN_LEVEL AuthnLevel,
     RPC_C_AUTHN AuthnSvc,
     ref SEC_WINNT_AUTH_IDENTITY AuthIdentity,
     RPC_C_AUTHN AuthzService);
コード例 #2
0
 public static extern RPC_STATUS RpcBindingInqAuthClient(
     IntPtr ClientBinding,
     ref IntPtr Privs,
     StringBuilder ServerPrincName,
     ref RPC_C_AUTHN_LEVEL AuthnLevel,
     ref RPC_C_AUTHN AuthnSvc,
     ref RPC_C_AUTHZ AuthzSvc);
コード例 #3
0
 public static extern RPC_STATUS RpcBindingInqAuthInfo(
     IntPtr Binding,
     StringBuilder ServerPrincName,
     ref RPC_C_AUTHN_LEVEL AuthnLevel,
     ref RPC_C_AUTHN AuthnSvc,
     ref IntPtr AuthIdentity,
     ref RPC_C_AUTHZ AuthzSvc);
コード例 #4
0
ファイル: Server.cs プロジェクト: pombredanne/NDceRpc
        private static bool serverRegisterAuthInfo(RPC_C_AUTHN auth, string serverPrincName)
        {
            RpcTrace.Verbose("serverRegisterAuthInfo({0})", auth);
            RPC_STATUS response = NativeMethods.RpcServerRegisterAuthInfo(serverPrincName, (uint)auth, IntPtr.Zero, IntPtr.Zero);

            if (response != RPC_STATUS.RPC_S_OK)
            {
                RpcTrace.Warning("serverRegisterAuthInfo - unable to register authentication type {0}", auth);
                return(false);
            }
            return(true);
        }
コード例 #5
0
        /// <summary>
        /// Adds authentication information to the client, use the static Self to
        /// authenticate as the currently logged on Windows user.
        /// </summary>
        public void AuthenticateAs(string serverPrincipalName, NetworkCredential credentials)
        {
            var types   = new [] { RPC_C_AUTHN.RPC_C_AUTHN_GSS_NEGOTIATE, RPC_C_AUTHN.RPC_C_AUTHN_WINNT };
            var protect = RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_PKT_PRIVACY;

            bool isAnonymous = (credentials != null && credentials.UserName == Anonymous.UserName && credentials.Domain == Anonymous.Domain);

            if (isAnonymous)
            {
                protect     = RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_DEFAULT;
                types       = new RPC_C_AUTHN[] { RPC_C_AUTHN.RPC_C_AUTHN_NONE };
                credentials = null;
            }

            AuthenticateAs(serverPrincipalName, credentials, protect, types);
        }
コード例 #6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="clientGuid">an object UUID which represents the RPC caller.</param>
 /// <param name="serverComputerName">the NetworkingAddress of the RPC server.</param>
 /// <param name="protocolSequence">a string representation of a protocol sequence.</param>
 /// <param name="endPoint">a string representation of an endpoint.</param>
 /// <param name="networkOptions">a string representation of network options. The option string is associated
 /// with the protocol sequence.</param>
 /// <param name="servicePrincipalName">the expected principal name of the server referenced by Binding.</param>
 /// <param name="authenticationLevel">Level of authentication to be performed on remote procedure calls
 /// made using Binding.</param>
 /// <param name="authenticationService">Authentication service to use.</param>
 /// <param name="authenticationIdentity">the structure containing the client's authentication and 
 /// authorization credentials appropriate for the selected authentication and authorization service.</param>
 /// <param name="authorizationService">Authorization service implemented by the server for the interface of
 /// interest.</param>
 public RpcClientConfig(
     Guid? clientGuid,
     String serverComputerName,
     String protocolSequence,
     String endPoint,
     String networkOptions,
     String servicePrincipalName,
     RPC_C_AUTHN_LEVEL authenticationLevel,
     RPC_C_AUTHN authenticationService,
     SEC_WINNT_AUTH_IDENTITY authenticationIdentity,
     RPC_C_AUTHN authorizationService)
 {
     this.clientGuid = clientGuid;
     this.serverComputerName = serverComputerName;
     this.protocolSequence = protocolSequence;
     this.endPoint = endPoint;
     this.networkOptions = networkOptions;
     this.servicePrincipalName = servicePrincipalName;
     this.authenticationLevel = authenticationLevel;
     this.authenticationService = authenticationService;
     this.authenticationIdentity = authenticationIdentity;
     this.authorizationService = authorizationService;
 }
コード例 #7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="clientGuid">an object UUID which represents the RPC caller.</param>
 /// <param name="serverComputerName">the NetworkingAddress of the RPC server.</param>
 /// <param name="protocolSequence">a string representation of a protocol sequence.</param>
 /// <param name="endPoint">a string representation of an endpoint.</param>
 /// <param name="networkOptions">a string representation of network options. The option string is associated
 /// with the protocol sequence.</param>
 /// <param name="servicePrincipalName">the expected principal name of the server referenced by Binding.</param>
 /// <param name="authenticationLevel">Level of authentication to be performed on remote procedure calls
 /// made using Binding.</param>
 /// <param name="authenticationService">Authentication service to use.</param>
 /// <param name="authenticationIdentity">the structure containing the client's authentication and
 /// authorization credentials appropriate for the selected authentication and authorization service.</param>
 /// <param name="authorizationService">Authorization service implemented by the server for the interface of
 /// interest.</param>
 public RpcClientConfig(
     Guid?clientGuid,
     String serverComputerName,
     String protocolSequence,
     String endPoint,
     String networkOptions,
     String servicePrincipalName,
     RPC_C_AUTHN_LEVEL authenticationLevel,
     RPC_C_AUTHN authenticationService,
     SEC_WINNT_AUTH_IDENTITY authenticationIdentity,
     RPC_C_AUTHN authorizationService)
 {
     this.clientGuid             = clientGuid;
     this.serverComputerName     = serverComputerName;
     this.protocolSequence       = protocolSequence;
     this.endPoint               = endPoint;
     this.networkOptions         = networkOptions;
     this.servicePrincipalName   = servicePrincipalName;
     this.authenticationLevel    = authenticationLevel;
     this.authenticationService  = authenticationService;
     this.authenticationIdentity = authenticationIdentity;
     this.authorizationService   = authorizationService;
 }
コード例 #8
0
ファイル: ProtocolsTests.cs プロジェクト: OpenSharp/NDceRpc
        static void ReversePingTest(RpcProtseq protocol, string[] hostNames, string endpoint, RPC_C_AUTHN auth)
        {
            Guid iid = Guid.NewGuid();
            using (ExplicitBytesServer server = new ExplicitBytesServer(iid))
            {
                server.OnExecute +=
                    delegate(IRpcCallInfo client, byte[] arg)
                    {
                        Array.Reverse(arg);
                        return arg;
                    };

                server.AddProtocol(protocol, endpoint, 5);
                server.AddAuthentication(auth);
                server.StartListening();

                byte[] input = Encoding.ASCII.GetBytes("abc");
                byte[] expect = Encoding.ASCII.GetBytes("cba");

                foreach (string hostName in hostNames)
                {
                    using (ExplicitBytesClient client = new ExplicitBytesClient(iid, new EndpointBindingInfo(protocol, hostName, endpoint)))
                    {
                        client.AuthenticateAs(null, auth == RPC_C_AUTHN.RPC_C_AUTHN_NONE
                                                      ? ExplicitBytesClient.Anonymous
                                                      : ExplicitBytesClient.Self,
                                                  auth == RPC_C_AUTHN.RPC_C_AUTHN_NONE
                                                      ? RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_NONE
                                                      : RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
                                                  auth);

                        Assert.AreEqual(expect, client.Execute(input));
                    }
                }
            }
        }
コード例 #9
0
 public static extern RPC_STATUS RpcBindingSetAuthInfo2(IntPtr Binding, String ServerPrincName,
                                                        RPC_C_AUTHN_LEVEL AuthnLevel, RPC_C_AUTHN AuthnSvc,
                                                        IntPtr p, RPC_C_AUTHZ AuthzService);
コード例 #10
0
ファイル: NativeMethods.cs プロジェクト: OpenSharp/NDceRpc
 public static extern RPC_STATUS RpcBindingInqAuthInfo(
     IntPtr Binding,
     StringBuilder ServerPrincName,
     ref RPC_C_AUTHN_LEVEL AuthnLevel,
     ref RPC_C_AUTHN AuthnSvc,
        ref     IntPtr AuthIdentity,
     ref RPC_C_AUTHZ AuthzSvc);
コード例 #11
0
        static void ReversePingTest(RpcProtseq protocol, string[] hostNames, string endpoint, RPC_C_AUTHN auth)
        {
            Guid iid = Guid.NewGuid();

            using (ExplicitBytesServer server = new ExplicitBytesServer(iid))
            {
                server.OnExecute +=
                    delegate(IRpcCallInfo client, byte[] arg)
                {
                    Array.Reverse(arg);
                    return(arg);
                };

                server.AddProtocol(protocol, endpoint, 5);
                server.AddAuthentication(auth);
                server.StartListening();

                byte[] input  = Encoding.ASCII.GetBytes("abc");
                byte[] expect = Encoding.ASCII.GetBytes("cba");

                foreach (string hostName in hostNames)
                {
                    using (ExplicitBytesClient client = new ExplicitBytesClient(iid, new EndpointBindingInfo(protocol, hostName, endpoint)))
                    {
                        client.AuthenticateAs(null, auth == RPC_C_AUTHN.RPC_C_AUTHN_NONE
                                                      ? ExplicitBytesClient.Anonymous
                                                      : ExplicitBytesClient.Self,
                                              auth == RPC_C_AUTHN.RPC_C_AUTHN_NONE
                                                      ? RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_NONE
                                                      : RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
                                              auth);

                        Assert.AreEqual(expect, client.Execute(input));
                    }
                }
            }
        }
コード例 #12
0
ファイル: Server.cs プロジェクト: OpenSharp/NDceRpc
 /// <summary>
 /// Adds a type of authentication sequence that will be allowed for RPC connections to this process.
 /// </summary>
 public bool AddAuthentication(RPC_C_AUTHN type, string serverPrincipalName)
 {
     return serverRegisterAuthInfo(type, serverPrincipalName);
 }
コード例 #13
0
ファイル: Server.cs プロジェクト: OpenSharp/NDceRpc
 /// <summary>
 /// Adds a type of authentication sequence that will be allowed for RPC connections to this process.
 /// </summary>
 public bool AddAuthentication(RPC_C_AUTHN type)
 {
     return AddAuthentication(type, null);
 }
コード例 #14
0
ファイル: Server.cs プロジェクト: OpenSharp/NDceRpc
 private static bool serverRegisterAuthInfo(RPC_C_AUTHN auth, string serverPrincName)
 {
     RpcTrace.Verbose("serverRegisterAuthInfo({0})", auth);
     RPC_STATUS response = NativeMethods.RpcServerRegisterAuthInfo(serverPrincName, (uint)auth, IntPtr.Zero, IntPtr.Zero);
     if (response != RPC_STATUS.RPC_S_OK)
     {
         RpcTrace.Warning("serverRegisterAuthInfo - unable to register authentication type {0}", auth);
         return false;
     }
     return true;
 }
コード例 #15
0
ファイル: Server.cs プロジェクト: pombredanne/NDceRpc
 /// <summary>
 /// Adds a type of authentication sequence that will be allowed for RPC connections to this process.
 /// </summary>
 public bool AddAuthentication(RPC_C_AUTHN type)
 {
     return(AddAuthentication(type, null));
 }
コード例 #16
0
 public static extern uint RpcBindingSetAuthInfo(
     IntPtr Binding,
     string ServerPrincName,
     RPC_C_AUTHN_LEVEL AuthnLevel,
     RPC_C_AUTHN AuthnSvc,
     ref SEC_WINNT_AUTH_IDENTITY AuthIdentity,
     RPC_C_AUTHN AuthzService);
コード例 #17
0
ファイル: NativeMethods.cs プロジェクト: OpenSharp/NDceRpc
 public static extern RPC_STATUS RpcBindingSetAuthInfo2(IntPtr Binding, String ServerPrincName,
                                                       RPC_C_AUTHN_LEVEL AuthnLevel, RPC_C_AUTHN AuthnSvc,
                                                       IntPtr p, RPC_C_AUTHZ AuthzService);
コード例 #18
0
ファイル: NativeMethods.cs プロジェクト: OpenSharp/NDceRpc
 public static extern RPC_STATUS RpcBindingInqAuthClient(
     IntPtr ClientBinding,
     ref IntPtr Privs,
     StringBuilder ServerPrincName,
     ref RPC_C_AUTHN_LEVEL AuthnLevel,
     ref RPC_C_AUTHN AuthnSvc,
     ref RPC_C_AUTHZ AuthzSvc);
コード例 #19
0
ファイル: Server.cs プロジェクト: pombredanne/NDceRpc
 /// <summary>
 /// Adds a type of authentication sequence that will be allowed for RPC connections to this process.
 /// </summary>
 public bool AddAuthentication(RPC_C_AUTHN type, string serverPrincipalName)
 {
     return(serverRegisterAuthInfo(type, serverPrincipalName));
 }