|
|
Hi
We are using Authorization and profile application blocks (Microsoft Design patterns).We are trying to access the Azman Provider we are not able to access the dll which is added in the references already in the client application.If you can provide us some code snippets that would be really very helpful.I am providing my client application here.
*******************Code*********************
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
//Error ,in accessing the reference that is added
using Microsoft.ApplicationBlocks.Security.Provider; //cannot access the provider.
using Microsoft.ApplicationBlocks.Security.Authorization;
using Microsoft.ApplicationBlocks.Security.Profile;
using Microsoft.ApplicationBlocks.Common.Crypto;
using System.Security.Principal;
using System.Configuration.Assemblies;
using System.Threading;
using Microsoft.Interop.Security.AzRoles;
namespace myClient
{
public class WebForm1 : System.Web.UI.Page
{
string userRole="Manager";
private void Page_Load(object sender, System.EventArgs e)
{
Microsoft.ApplicationBlocks.Security.ExtendedPrincipal principal = Microsoft.ApplicationBlocks.Security.ExtendedPrincipal.Create(Thread.CurrentPrincipal.Identity);
Thread.CurrentPrincipal =principal;
principal.AuditIdentifier ="MyAuditIdentifer";
principal.AuthorizationProvider="azmanProvider";
principal.AuthorizationParameters.Add(AzManProvider.ApplicationName,"myApplication");
if(Thread.CurrentPrincipal.IsInRole(userRole))
{
((ExtendedPrincipal)Thread.CurrentPrincipal).AuthorizationParameters.Add("tasks",new string[1] {"AddOrderTask"});
if ( ((ExtendedPrincipal)Thread.CurrentPrincipal).CheckAccess())
{
//quickStart.AddOrder();
}
else
{
Response.Write("Add Order Access Denied");
}
}
Hashtable parameters = new Hashtable(5);
parameters.Add("principal",Thread.CurrentPrincipal);
((ProfileCollection)((ExtendedPrincipal)
Thread.CurrentPrincipal).Profile).
Initialize((ExtendedPrincipal)Thread.CurrentPrincipal);
// Accessing the Profile Information from the ProfileCollection:
Response.Write("Profile Information from the Profile Collection thru the ExtendedPrincipal");
Response.Write("Profile Information: 'Preferred Investment Type' is "+(string)((ProfileCollection)
((ExtendedPrincipal)Thread.CurrentPrincipal).
Profile)["stockProfile"]["preferredInvestmentType"].Value );
Response.Write("Profile Information: 'Trades Frequently' is " +
Boolean.Parse(((string)((ProfileCollection)
((ExtendedPrincipal)Thread.
CurrentPrincipal).Profile)["stockProfile"]
["tradesFrequently"].Value)));
Response.Write("Profile Information: 'Most Traded Stocks' is " +
(string)((ProfileCollection)
((ExtendedPrincipal)Thread.CurrentPrincipal).
Profile)["stockProfile"]["stockTrades"]
["mostTradedStocks"].Value);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
With Many Thanks
kiran
|
|
|
|
|
This is probably one of the strangest things I think I've seen while working in .NET and I have yet to figure out even a workaround, much less why it might be occurring.
I've got a very strange bug happening which I was finally able to distill down to a problem with writing to ..\..\app.config after a file open dialog. It appears that if a standard file open dialog is closed with the "open" button then any future writes to app.config just magically disappear into the bit bucket (am I the only one still using that term?). No errors, no exceptions thrown. In fact, if you close the app.config stream and open it from scratch, the changes just written appear to be there but when the app finishes, they aren't there. This sounds like a buffering problem but I'm setting the stream to autoflush and flushing/closing it after the save. Also, if you have the file open in the IDE at the time, you can write to it and save it just fine. None of this happens when you hit the cancel key in the open file dialog even though I'm totally ignoring the return from the dialog in both cases. None of it happens with files other than ..\..\app.config (at least not with the sample file I tried in my temp directory).
I have no idea why the file open dialog and app.config would be tied together in such an inextricable manner. I don't know how I'd simulate such a strange situation WRT app.config even if I tried. The best I can think of is to overwrite app.config and change it's creation date back to what it was originally but this isn't happening because I can write to it from the IDE while this is happening and those writes aren't overwritten. This one definitey has me scratching my head.
To illustrate the bug I wrote a tiny app with a single button which calls the following function when the button is pressed. This pretty much illustrates everything I'm talking about (forgive the formatting - all my blank lines seem to drop out in the <pre> block - anybody know how to get them to show up?):
private void XMLBugSave()
{
const string strFile = @"..\..\app.config";
XmlTextReader xr = new XmlTextReader(strFile);
xdoc = new XmlDocument();
xdoc.Load(xr);
xr.Close();
Random rnd = new Random();
string strNodeName = "NODE_" + rnd.Next().ToString();
Console.WriteLine("Attempting to add Element " + strNodeName);
xdoc.DocumentElement.AppendChild(xdoc.CreateNode(XmlNodeType.Element, strNodeName, null));
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog();
StreamWriter sw = new StreamWriter(strFile);
sw.AutoFlush = true;
xdoc.Save(sw);
sw.Flush();
sw.Close();
MessageBox.Show("Verify file...");
xr = new XmlTextReader(strFile);
xdoc = new XmlDocument();
xdoc.Load(xr);
xr.Close();
XmlNode xn = xdoc.SelectSingleNode(@"/configuration/" + strNodeName);
Console.WriteLine(xn == null ? "unverified" : "verified");
}
|
|
|
|
|
you'll kick yourself when you read this.
.NET Framework Class Library
OpenFileDialog.OpenFile Method
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsopenfiledialogclasstopic.asp
|
|
|
|
|
Hi,
I have developed a .NET application. What is currently missing is a copy protection. My customers are mostly in other cities and in same sector. When I send a copy to a customer I want to be sure that it is not copied and used without my knowledge. What do you use to protect your applications?
|
|
|
|
|
Hi all,
I've created an ActiveX control using Visual C++ .NET.
When I add this control to a container created with Visual C++ .NET (or a Visual C++ 6.0) everything works and there is no apparently problem. But now, I'm trying to test this ActiveX with an application created with Visual Basic 6.0. The problem is that the ActiveX control does not appear in the list of registered components from the Visual Basic 6.0 (Menu -> Project -> Components, or Ctrl+T). So, I can't add my ActiveX to the Visual Basic 6.0 container.
When I try to make the same operation with a Visual Basic .NET container, I find the same situation, this is, the ActiveX control is not in the registered components list. But the ActiveX control is already registered.
I use the OleView application in order to ensure that the control is registered.
Due to my ActiveX control perfectly works with a Visual C++ .NET (and a Visual C++ 6.0) container, I suppose there is any bad chosen compiler option (by the time, everything is by default). Does anybody experimented the same situation testing his/her ActiveX in a Visual Basic container?
Thanks in advance.
|
|
|
|
|
I need to draw a chart (in 2D) and I'm programming in Visual C++ (.NET version 2003). I can´t use the controls in: http://www.codeproject.com/miscctrl/#Charting+Controls
because I'm not using MFC.
I've read that there is an ActiveX control called Microsoft chart Control but I don´t know how to use an ActiveX control in visual c++.
Please help me!!!
|
|
|
|
|
You can import the type library for Microsoft Graph (a COM component of Microsoft Office), and use the Type Library Importer (TLBIMP.EXE) to convert this to an assembly, which you can examine with the IL Disassembler. However, this is a major pain in the ass and it takes alot of time to learn your way through it all. There are help files for all the Microsoft Office components, located somwhere in that directory, but they are written for Visual Basic programmers. They do however describe the object hierarchy well enough to get you started.
It would be mush easier to actually draw the chart using GDI functions.
How complex is the chart? Do you have to create many of them?
|
|
|
|
|
It's a XY chart, I think that it's not very complicated. I have to create a lot of points and then draw lines from one point to another with DrawLine. Am I right? Is there a way to make it easier?
I have a variable number of points, and it can reach a high number so I won´t have enough pixels to draw the chart. In that case I don´t know what to do.
Thanks ursus zeta for replying
|
|
|
|
|
Hey, sorry for not getting back to you.
I'm used to using the GDI functions in Win32 applications, so I haven't done much design in .NET. But the Framework classes call the underlying Win32 functions, which, in this case are pretty simple and commonly used. The Graphics object is similar to the Device Context in the Win32 API. I believe you instantiate the Graphics object (with the new operator), and then, you can use Intellisense to help you through the process.
In Win32, you specify a point, and then to draw a line (after selecting a Pen into the Device Context) you call two functions, the first sets the beginning and the second draws the line to the end point (which you supply as a parameter). It's quite simple; and, I'm sure the .NET Framework methods are as easily used (but, I haven't played around with it, so, I have no example code).
You might read through the MSDN documentation, and explore the DrawLine method:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawinggraphicsmemberstopic.asp[^]
|
|
|
|
|
hi all ...
i'm developing a program that gets all the processes running on the computer and display them in a list view control and i'm using a timer that update the processes in the listview every 2 sec...the problem is that if there is a selected item in the list view and the list view updated .. the selection on the item just gone ...how can i track the selected item so that the next time the list view updated ....the same item is still selected...
thank you for your time
|
|
|
|
|
Hi, there isn't any simplier method, than store name of selected item in local variable, refresh listview and find item with same name as you have in local variable.
Something like this:
string name="";
if (view.SelectedItems.Length!=0)
name=view.SelectedItems[0].Text;
for(int i=0; i<view.Items.Length; i++)
{
if (view.Items[i].Text==name)
{ view.SelectedIndices[i]=true; break; }
}
|
|
|
|
|
hi all.. i'm developing a program that get the current processes that are running on the computer and if any process has i user interface getting the name of this GUI of the process...i'm checking if the process has MainWindowHandler...if so i'm getting the process MainWindowTitle....it is working fine but for processes such as Explorer.exe or Iexplorer.exe ... the MainWindowTitle doesn't return anything...i wanna return the urls that the ie launching ...or the folders that are opened now...how can i accomplish this??
thank for ur time
|
|
|
|
|
I have written a custom OLE DB Provider for a propritary Database (built on top of SQL Server provider). I want to move all my code to .NET from VC 6. Since the .NET Data Providers do not provide functionality outside of ADO.NET (Like in Excel or Crystal Reports) I cannot use the new data provider platform. Is there a way through COM interop that I can consume a datatable in COM so I can have a .NET dll that does 90% of the work with my original provider code consuming the output of the new dll. I have seen all the COM interop examples and they all use the basic types like string double etc. If anyone has any ideas please let me know.
|
|
|
|
|
I am trying to write a black and white (Tiff) image viewer using GDI+ in C#. I want to take a 1 bpp tiff file and display it to the user in "Grayscale". Does anyone have any examples of this type of filter? I am looking to mimic the "softening" of the tiff image that can be seen if viewing a tiff in the Windows Picture and Fax viewer or the MODI viewer. I can get misc. filters to work on jpg images, but and having difficulty working with 1bpp tiffs. Any help is much appreciated.
Brian
|
|
|
|
|
check this and ask Christian Graus here on CP
http://www.thecodeproject.com/cs/media/csharpgraphicfilters11.asp
|
|
|
|
|
Hi,
We’re in the process of designing a server-side application.
The first "filter" component of the server should receive requests from multiple concurrent clients over TCP/IP, each request containing an entity ID number. The filter should then process each ID and decide whether to pass it on to the next component (database) according to a given set of rules. The first version of the system should deal with around 20 concurrent clients producing ~1,000 requests per second, but future versions should be much more scalable (up to hundreds of concurrent clients and ~100,000 requests per second). The development environment is Microsoft .NET on Windows 2000 servers.
We came up with two possible architectures for the filter component:
1. Maintain a different communication thread for every client. Every such communication thread receives ID’s from its corresponding client and writes them into a common queue. A different worker thread reads data from the queue and processes the requests.
2. Maintain one communication thread for all clients. The communication thread reads ID’s and writes them into a queue. Several worker threads, managed in a thread pool, read data from the queue and process requests.
The first solution is obviously less scalable, since when the number of clients increases the overhead of a large number of threads starts affecting performance. Still, it is easier to code and it fits the first version/versions of the server.
Our question regarding the second solution, which seems more "server-oriented", is this: when taking into consideration the large number of requests per second and the fact that the processing time of each request is relatively short, isn’t the overhead of managing a thread pool, allocating a worker thread for every new request and returning it back to the pool when finished, etc. becoming too expensive ? Won't this affect the overall performance ?
In addition:
1. What should be the limit (roughly speaking) of the number of concurrent communication threads we can expect to run on a standard Windows 2000 machine ?
2. Is there any other alternative for the design of the filter component ? Are we missing something basic ?
Thanks in advance,
Amir.
|
|
|
|
|
Hi...
Is it possible to catch every single mouse click message like WM_LBUTTONDOWN regardless which application is active? I tried using IMessageFilter but it is limited to the current application.
Thanks
|
|
|
|
|
|
I want to make my own custom .NET framework launch condition message. I've tried to simply change the message property in the Condition node but that didn't work. I've read the "Adding a .NET Framework Launch Condition" section in Visual Studio help. It says "You can replace this with your own message; however, the message will not be localized automatically". This may be a newbie question but how do I localize my custom message?
|
|
|
|
|
I kept the default message, wrote my message outside of the brackets and it worked but the default message still showed up in the message box.
|
|
|
|
|
I would like to check if any specific program, e.g. Excel, running.
Can anyone here help me?
Same effect as when upgrading IE, it will check if there is any IE running, if yes, it will warn the user to close all IE before continue.
Thank You!!! ;)
|
|
|
|
|
Hi,
Using the System.Diagnostics namespace, you can do this:
Process[] excelProcs = Process.GetProcessesByName("excel");
if (excelProcs.Length > 0)
// there we have excel.exe(s) running
|
|
|
|
|
Hi All,
I have some frames(GroupBoxes) for my application and would like to know when the mouse comes onto the frame(GroupBox). Any ideas please. Or can I know the coordinates of the mouse when I am on the frame(GroupBox)(Some thing like that)
Thanks in advance.
Sreepathi
|
|
|
|
|
.NET Framework Class Library
Control.MouseHover Event
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclassmousehovertopic.asp
|
|
|
|