|
I dont even know if this is possible , but...
The company i work for uses 802.11x for wireless authentication. We have an issue regularly where the certificates expire or become invalid, because usually because the user has changed their password recently, and a bug in Microsoft's software causes it to fail on the automated request.
What i am looking to do is create a web page that will sit on our intranet that will allow users to request a new certificate based on who they are. We currently have to walk the user through going into MMC and walking through the certificate request procedure.
This is particularly timely since we had an issue recently that expired every certificate on the network....
i do know there is a certificate namespace, and since MMC allows for the request, there MUST be a way to use the object for this procedure, I am just at a loss where to start tocreate a page for it.
_________________________________________
Yes, I am the highly suggestable type.
|
|
|
|
|
Microsoft Certificate Services actually already has this functionality, and you can set up a CA site easily. I suggest you read the product documentation for Microsoft Certificate Services. I set up such a site with very few steps some time back on our network and it was quite easy, but I don't remember all that I did.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I'm trying to replace some text in an html file based on some regular expressions (or literal text) in a text file.
What should happen is that "A0-1234" in the html file should get replaced by:
"<a href="javascript:selectItem('A0-1234',42)">A0-1234</a>"
and "B1-123456" in the html file should get replaced by:
"<a href="javascript:selectItem('B1-123456',42)">B1-123456</a>"
and so on...
Here's what I'm doing:
static void Main(string[] args)
{
/* For following code:
* i - input; c - config; o - output;
* Therefore, isr - input streamreader, csr - config streamreader,
* cline - config line, iline - input line
*/
String ifile = "data.html";
String cfile = "config.txt"
String ofile = "newdata.html"; // output file name
string cline;
string iline="";
try
{
// open a StreamReader to read in the input file
using (StreamReader isr = new StreamReader(ifile))
{
// Read in the entire input file into a single string
iline = isr.ReadToEnd();
// open another StreamReader to read in the config file
using (StreamReader csr = new StreamReader(cfile))
{
// open a StreamWriter to write out to the output file
using (StreamWriter sw = new StreamWriter(ofile))
{
// Read in the config file, one line at a time.
// Each line corresponds to an expression to be matched
// in the input file
while ((cline = csr.ReadLine()) != null)
{
// Set every line of the config file as the
// regular expression to be tested for
Regex testExp = new Regex( cline );
/*
// Setup the replacement string
// INSTEAD OF cline, USE MATCHED VALUE
string replaceString = "<a href=\"javascript:selectItem(\'" + cline + "\',42)\">" + cline + "</a>";
*/
if (iline != null)
{
// Replace all matched expressions with the
// appropriate function
Match m = Regex.Match( iline, cline );
String replaceString = "<a href=\"javascript:selectItem(\'" + m.ToString() + "\',42)\">" + m.ToString() + "</a>";
m = m.NextMatch();
iline = testExp.Replace( iline, replaceString );
Console.WriteLine(iline);
}// end if iline
} // end while cline
// Write the replaced text back to the output file
// using the StreamWriter
sw.Write(iline);
} // end using streamwriter sw
} // end using StreamReader csr
} // end using StreamReader isr
} // End Try block
catch (Exception e)
{
Console.WriteLine("The file could not be read:");
Console.WriteLine(e.Message);
} // End catch block
} // End Main
Now the problem is that ALL matches of a regular expression in the config file (say "[A-Z,a-z]\d-\d{4,8}", which matches "A0-1234", "B6-12345678", "D4-12345" etc) get replaced by the first match...
So if the first expr matched in the input html file is "A0-1234", then all other expressions in the html file get replaced by :
"<a href="javascript:selectItem('A0-1234',42)">A0-1234</a>"
even if those expressions are "B4-12345", "T6-886745" or anything else that matches "[A-Z,a-z]\d-\d{4,8}"
Please help.....
|
|
|
|
|
Hy everyone!
I was just having a look how to get the cursor postion.
Because I do want a context menu pop up at the cursor position.
I did the contextmenu, but I didn't manage to make it appear!
My contextmenu looks like this:
System.Windows.Forms.ContextMenu ctNameKeyMenu;
ctNameKeyMenu = new System.Windows.Forms.ContextMenu();
System.Windows.Forms.MenuItem menuItem1;
menuItem1 = new System.Windows.Forms.MenuItem();
System.Windows.Forms.MenuItem menuItem2;
menuItem2=new System.Windows.Forms.MenuItem();
ctNameKeyMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {menuItem1, menuItem2});
menuItem1.Index=0;
menuItem1.Text=ltemparray[1].ToString();
menuItem2.Index=1;
menuItem2.Text=ltemparray[2].ToString();
// show the contextmenu at the local mouseposition
ctNameKeyMenu.Show(lTextBox, ???);
lTextBox in the line above is the TextBox the contextmenu should appear for respectively appear in. I do know I have to put a point object in there as the second parameter. But well how do I get the MousePos?? Because I can't simply type MousePos() in there!
Thanks!
Stephan.
|
|
|
|
|
Cursor.Position should give you the mouse position I believe
|
|
|
|
|
Yup, I had this one, but the result was quit strange, because the context appeared around as far from the cursor as the cursor was located rom the upper left corner of my application window! Meaning the upper left corner of the context was twice the distance of the mouse distance of the left corner of the application.
Do you have an idea why?
Because I also tried Control.MousePosition.
Same result!
Because I can't find out why!
And a second question: When selecting one of the MenuItems I do want the selected one to being placed in the TextBox the Context "belongs" to. But to do so, I do have to create an eventhandler for the clickevent, but then I do loose access to my TextBox.
Well it looks like this:
....
System.Windows.Forms.ContextMenu ctNameKeyMenu;
ctNameKeyMenu = new System.Windows.Forms.ContextMenu();
System.Windows.Forms.MenuItem menuItem1;
menuItem1 = new System.Windows.Forms.MenuItem();
System.Windows.Forms.MenuItem menuItem2;
menuItem2=new System.Windows.Forms.MenuItem();
ctNameKeyMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {menuItem1, menuItem2});
menuItem1.Index=0;
menuItem1.Text=ltemparray[1].ToString();
menuItem1.Click += new System.EventHandler(this.menuItem1_Click();
menuItem2.Index=1;
menuItem2.Text=ltemparray[2].ToString();
menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
ctNameKeyMenu.Show(lTextBox, Control.MousePosition);
.....
// same for menuItem2
private void menuItem1_Click(object sender, System.EventArgs e)
{
// assign the selected item of the context to the TextBox
}
But in the Clickevent section my TextBox is no longer accessible. So how do I get it in there? The selected item is available in the sender object, but this doesn't really help much.
Thanks again!
Stephan.
|
|
|
|
|
If you would read the documentation for the Cursor.Position property in the .NET Framework SDK, you'd see that the coordinate it in screen coordinates, so you must call PointToClient on the Control for which you want to transform the coordinates (relative to the Control ), passing the Cursor.Position to get a Point relative to the control:
Point p = button1.PointToClient(Cursor.Position);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks the hint worked!
Well I read this section, but I didn't count my application to be the client to the screen! But looking at it now, it looks clear and I am wondering why I didn't realize it earlier!
So then I can switch my task towards the event which has to take place when selecting an item in the context, namely assining it to the TextBox.
Thanks again!
Stephan.
|
|
|
|
|
|
If you want the algorithms supported by the CryptoAPI, then you'll have to P/Invoke a lot of CryptoAPI function and define lots of structs and consts to do it; otherwise, you can build an MC++ assembly without going to all that work. Either way, CryptEnumProviders is what you want to call, but this only enumerates CSPs supported by the CryptoAPI - not by .NET (which only encapsulates the standard CSPs). In addition, CSPs can be added using the <cryptographySettings> element which isn't used by an IConfigurationSectionHandler (technicall, the IgnoreSectionHandler is configured for that section) that you can use to query what's been added. CSPs can also be used without being registered in this way, like a TwoFish implementation I saw some time back.
The point is that there is not a single way to get what CSPs are available.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I am using service written by somebody else. I want to do some modifications in that. When I did modifications, I am seeing that service is stopping immediately. Do any body this kind of exp?? I am not getting any compile time or run time errors...
What is the reason for this.
Regards,
Satya
|
|
|
|
|
Where is the application stopping? Have you tried setting break points? Are any errors being thrown?
|
|
|
|
|
Hey everyone. Thanks in advance for any help. I have a WIN32 application that I am having difficulties with.
I basically have an ADD button for which you are able to add checkboxes at runtime. Then, I also have a REMOVE button which removes any checkboxes that are checked when the button is pressed. My difficulty lies in how to reference the checkboxes because they are all created at runtime. Here is some of my code.
<br />
function (int currentnumber) {<br />
<tab>myCheckBox = new System.Windows.Forms.CheckBox();<br />
this.panel1.Controls.Add(myCheckBox);<br />
myCheckBox.Location = new System.Drawing.Point(this.Group_label.Left-30, ystarter+(currentNumber*distance));<br />
myCheckBox.Name = "checkBox"+currentNumber;<br />
Console.WriteLine(myCheckBox.Name);<br />
myCheckBox.Size = new System.Drawing.Size(16, 24);<br />
myCheckBox.TabIndex = 6;<br />
}<br />
<br />
private void Remove_Group_Click(object sender, System.EventArgs e) {<br />
for(int i=1;i<=totalGroups;i++) { <br />
if (checkBox"+i.Checked == true) {<br />
this.panel1.Controls.Remove(checkBox"+i);<br />
}<br />
}<br />
}<br />
My REMOVE button click handler does not work properly. I can't get it to compile because it says that checkBox+i is not a valid Checkbox.
How do I reference my checkboxes that were created at runtime whose names should be:
checkBox1,checkBox2,....
Thanks again for any help.
|
|
|
|
|
That's not a valid variable name. You must enumerate your Controls and find a CheckBox with that name:
private Control GetControl(string name, bool caseInsensitive)
{
if (name == null) throw new ArgumentNullException("name");
foreach (Control c in Controls)
if (string.Compare(name, c.Name, caseInsensitive) == 0) return c;
return null;
} This returns a reference to a Control , so you can use the is statement to easily determine if it's a checkbox, or just recode the sample above to enumerate all Control s but in the conditional additionally use is to check if it's a CheckBox . Don't change Control c to CheckBox c (or something) because any control that is not a CheckBox will not cast and an exception will be thrown when enumerating.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Can someone tell me what is wrong with this code.
I've got a couple of custom controls in a groupbox that i need to dispose. I tried the following foreach loop, but i get the error "Specified cast not valid".
foreach (WorkersCtrl c in groupBox.Controls)
{
c.dispose();
}
Thanks.
|
|
|
|
|
But that's very simple: at least one of the Control s in groupBox.Controls is not a WorkersCtrl .
The Controls collection holds Control s or derived classes, not limited to WorkersCtrl only.
If you really only want to call Dispose() then change WorkersCtrl c into Control c and you'll be fine.
mav
|
|
|
|
|
Thanks, it was pretty stupid of me. I've got it working now.
|
|
|
|
|
You must have a control inside the groupbox that is not of or inherit from WorkersCtl. You could try a couple of different things. You could either throw an if statement in there, to determine if the object is of type WorkersCtrl, and just use the object base class inside your for each decleration. Or...., you could change workersctrl to object, and set a debug statement within the foreach statement, outputing each objects .gettype().tostring() to determine which object is throwing the invalid cast error.
|
|
|
|
|
Hi all,
I have a problem concerning Crystal Report's performance on Win2000.
I use datasets to push data into my report, but the assignment of the datasource to the report and the the creation of the report take way too much time on some Win2000 systems.
Here are the two code snippets that take so much time:
report.SetDataSource(dataSet);
ReportForm reportForm = new ReportForm(report, m_ResourceManager);
reportForm.Show()
Some examples of the performance of this code:
On my Windows XP:
SetDataSource: 3 seconds
show report: 2 seconds
A colleague's Win 2000:
SetDataSource: 2 seconds
show report: 2 seconds
Another colleague's Win 2000:
SetDataSource: 105 seconds
show report: 391 seconds
My application runs fine on every Windows XP that I tested and it also runs fine on some Win2000 systems.
But unfortunately there are some Win2000 systems that have very bad performance running my app.
I have no clue what could be the reason for this.
For example:
The Win2000 system's load is at about zero percent, when it is waiting for the SetDataSource method to return.
How can this be?
Any help appreciated.
Best regards
Bernd R.
-------------------------------------------
The light at the end of the tunnel has been switched off temporarily due to budget problems...
|
|
|
|
|
While Crystal Reports is not the most stable product in the computing world, I doubt this is the cause of your problem. I'd check first the database connections and/or the ammount of data that is being trasnferred on the slow machines.
Yes, even I am blogging now!
|
|
|
|
|
Database connection shouldn't be the problem, because there is no database. I use datasets!
And the amount of data transferred is not very high.
I also don't think that the hardware is the problem, because we use computers with Pentium4 2,8GHz and 512 MB of RAM.
I guess this must be some weird configuration issue
-------------------------------------------
The light at the end of the tunnel has been switched off temporarily due to budget problems...
|
|
|
|
|
Hi,
I am using a Stored Procedure to validate Login Process:
Stored Procedure is defined as follows :
----------------------------------------------------------
CREATE PROCEDURE spCheckLogin
@LoginID char(20), @Pwd char(8), @Response int OUTPUT
AS
IF EXISTS (SELECT * FROM tEmployees WHERE LoginID=@LoginID AND Pwd=@Pwd)
Return 1
ELSE
Return 0
GO
----------------------------------------------------------
In C#, I am accessing this Stored Procedure as follows:
try
{
string temp="";
//open the connection
gvDatabase.scInventoryControl.Open();
//create the sql
sql = "spCheckLogin";
//create command
cmdLogin = new SqlCommand(sql,gvDatabase.scInventoryControl);
cmdLogin.CommandType=CommandType.StoredProcedure;
cmdLogin.Parameters.Add("@LoginID", SqlDbType.Char,20);
cmdLogin.Parameters["@LoginID"].Value=log;
cmdLogin.Parameters.Add("@Pwd", SqlDbType.Char,8);
cmdLogin.Parameters["@Pwd"].Value=p;
cmdLogin.Parameters.Add("@Response",SqlDbType.Int,4);
cmdLogin.Parameters["@Response"].Direction=ParameterDirection.Output;
Console.WriteLine("Data Access started");
cmdLogin.ExecuteNonQuery();
temp = cmdLogin.Parameters["@Response"].Value.ToString();
Console.WriteLine(temp);
//clean up code
cmdLogin.Dispose();
gvDatabase.scInventoryControl.Close();
Console.WriteLine("Data Access Closed");
}
catch(Exception ex) { Console.WriteLine(ex.ToString() ); }
------------------------------------------------------------
However It doesn't print any values, although I values do exists in the table
What am i doing wrong?
ThANX in ADvance
|
|
|
|
|
looks to me you got two thing mixed up.
you should eighter change youre sql code to
=======================
CREATE PROCEDURE spCheckLogin
@LoginID char(20), @Pwd char(8), @Response int OUTPUT
AS
IF EXISTS (SELECT * FROM tEmployees WHERE LoginID=@LoginID AND Pwd=@Pwd)
SET @Response=1
ELSE
SET @Response=0
GO
========================
OR you should use something like this in youre code:
========================
string temp="";
//create the sql
string sql = "spCheckLogin";
//create command
cmdLogin = new SqlCommand(sql,gvDatabase.scInventoryControl);
cmdLogin.CommandType=CommandType.StoredProcedure;
cmdLogin.Parameters.Add("@LoginID", SqlDbType.Char,20);
cmdLogin.Parameters["@LoginID"].Value=log;
cmdLogin.Parameters.Add("@Pwd", SqlDbType.Char,8);
cmdLogin.Parameters["@Pwd"].Value=p;
cmdLogin.Parameters.Add("@Response",SqlDbType.Int,4);
cmdLogin.Parameters["@Response"].Direction=ParameterDirection.Output;
Console.WriteLine("Data Access started");
try
{
//open the connection
gvDatabase.scInventoryControl.Open();
//use the connection
temp=(string)cmdLogin.ExecuteScaler();
Console.WriteLine(temp);
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString() );
}
finally
{
//clean up code
gvDatabase.scInventoryControl.Close();
Console.WriteLine("Data Access Closed");
}
cmdLogin.Dispose();
========================
i hope this helps.
(p.s. i did not test above code)
cookies are for eating, not for websites.
|
|
|
|
|
Try...
// Add the return value parameter
SqlParameter param = m_oCommand.Parameters.Add( "RETURN_VALUE", SqlDbType.Int );
param.Direction = ParameterDirection.ReturnValue;
D!shan
|
|
|
|
|
In namespace WindowsApplication1 I declare the richTextBox1 which I want to CALL FROM OTHER NAMESPACES MANY TIMES MAKING CHANGES that I want TO STAY. How I could make it for maximum performance ?
The first time I declared it as public static removing the keyword this in front of it.
But every time I was going to the Form1.cs[Design]* and I was making just a little change to the richTextBox1 the static was leaving and the this was appearing again.(Can I stop it happens?)
The second time I was passing the richTextBox1 as reference variable for many functions. But I think it is slow.(Is it realy slow?)
|
|
|
|
|