Microsoft.Protocols.TestSuites.MS_OXORULE.OxnspiInterop.GetBindHandle C# (CSharp) Method

GetBindHandle() private method

private GetBindHandle ( ) : IntPtr
return System.IntPtr
        public static extern IntPtr GetBindHandle();
        #endregion

Usage Example

Example #1
0
        /// <summary>
        /// Initialize the client and server and build the transport tunnel between client and server.
        /// </summary>
        private void InitializeRPC()
        {
            string serverName = Common.GetConfigurationPropertyValue("SutComputerName", this.site);
            string userName   = Common.GetConfigurationPropertyValue("AdminUserName", this.site);
            string domainName = Common.GetConfigurationPropertyValue("Domain", this.site);
            string password   = Common.GetConfigurationPropertyValue("AdminUserPassword", this.site);

            // Create identity for the user to connect to the server.
            OxnspiInterop.CreateIdentity(
                domainName,
                userName,
                password);
            MapiContext rpcContext = MapiContext.GetDefaultRpcContext(this.site);

            // Create Service Principal Name (SPN) string for the user to connect to the server.
            string userSpn = string.Empty;

            userSpn = Regex.Replace(rpcContext.SpnFormat, @"\[ServerName\]", serverName, RegexOptions.IgnoreCase);

            // Bind the client to RPC server.
            uint status = OxnspiInterop.BindToServer(serverName, rpcContext.AuthenLevel, rpcContext.AuthenService, rpcContext.TransportSequence, rpcContext.RpchUseSsl, rpcContext.RpchAuthScheme, userSpn, null, rpcContext.SetUuid);

            this.site.Assert.AreEqual <uint>(0, status, "Create binding handle with server {0} should success!", serverName);
            this.rpcBinding = OxnspiInterop.GetBindHandle();
            this.site.Assert.AreNotEqual <IntPtr>(IntPtr.Zero, this.rpcBinding, "A valid RPC Binding handle is needed!");
        }