|
Hey all -
I'm a total newb, and I'm trying to use the WSUS API to connect to a specified WSUS Server and "do stuff". The problem is that it currently uses the currently logged on use to connect to the WSUS server, which fails. If I do a "run as" on the program, and use the correct credentials, it works.
So, the question is how to prompt for credentials (command line) and connect to the WSUS server?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Microsoft.UpdateServices;
using Microsoft.UpdateServices.Administration;
namespace WSUS_Check
{
class Program
{
static void Main(string[] args)
{
string Server;
int Port, ans, count;
bool Secure;
ArrayList TGIDs;
System.Console.WriteLine("*******************************************************************************");
System.Console.WriteLine("Custom WSUS Check, v0.01");
System.Console.WriteLine("*******************************************************************************");
System.Console.WriteLine();
System.Console.Write("WSUS Server: ");
Server = System.Console.ReadLine();
System.Console.Write("Port: ");
Port = int.Parse(System.Console.ReadLine());
do
{
System.Console.Write("Secure [1\\0]: ");
ans = int.Parse(System.Console.ReadLine());
} while ( (ans != 1) && (ans != 0) );
if (ans == 1)
{
Secure = true;
}
else
{
Secure = false;
}
IUpdateServer Host;
try
{
Host = AdminProxy.GetUpdateServer(Server, Secure, Port);
System.Console.WriteLine("Connected to " + Host.Name.ToString() + " [WSUS v. " + Host.Version.ToString() + "]");
System.Console.WriteLine();
System.Console.WriteLine("Client groups on " + Host.Name.ToString() + ":");
ComputerTargetGroupCollection CTC = Host.GetComputerTargetGroups();
count = 0;
foreach (IComputerTargetGroup TG in CTC)
{
System.Console.WriteLine("[" + count + "] " + TG.Name.ToString() + ", " + TG.Id.ToString());
count++;
}
}
catch (Exception e)
{
System.Console.WriteLine();
System.Console.WriteLine(e.Message);
}
System.Console.WriteLine();
System.Console.WriteLine();
System.Console.WriteLine("Press any key to continue... ");
System.Console.ReadKey();
}
}
}
|
|
|
|
|
Since this is a console app, you could just create a batch file to run your program as who ever with the runas command.
That way you don't need to have have to modify your code.
Just because we can; does not mean we should.
|
|
|
|
|
Sure, that's one way, but not the way I'd like to see it done.
The code has to be modified anyways, midas well do it now. Plus I can learn the an auth. peice from this, which will be cool.
|
|
|
|
|
Did you find a solution for this? I am facing the same problem. If you found a solution can you share the sample code.
|
|
|
|
|
save key board strokes in a file byt using a windows service
|
|
|
|
|
...? Thats not even a question, and it sounds like some kind of malware keylogging thing.
Perhaps if you could elaborate a little more.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
yes , when we use internet all urls , chatting , e-mail's should be recorded into a file and that file should be invisible to see until we go to the "FOLDER OPTIONS" and enable to show files
|
|
|
|
|
1 - ask real questions, as in full sentences
2 - if you want to do something that could be used for extreme nastiness, you better explain your benign use for it and pray we believe you.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I'll give you the benifit of the doubt and assume your not up to anything nasty!
As a service it's pretty much impossible for reasons described here[^].
If your application has a legitimate purpose, then your end user won't object to a program running from the tray at least, in which case this[^] and this[^] may be of use.
Dave
|
|
|
|
|
DaveyM69 wrote: I'll give you the benifit of the doubt and assume your not up to anything nasty!
I'd assume the worst, when someone posts like that. I'd hate to be the one who gave the code that stole your credit card no.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Good Day,
Whenever I want to read a file, I always use:
byte[] stream = File.ReadAllBytes(path);
It worked fine for me in my past projects but now, I am reading files that are 200mb in size and File.ReadAllBytes won't present the progress of the file reading.
Thru googling, I found out that I can use BinaryReader to read files. But I don't know how to read it using the "OLD APPROACH" like using a loop and read the file chunk by chunk so I can compute for the progress.
So basically, my question is, how to use BinaryReader to read files using a a loop.
Thanks!
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
|
|
|
|
|
Its simple, you have a buffer of size N and you try to read N bytes from your file into this little buffer. The Stream.Read(...) method returns and int representing the number of bytes actualy read, so you then use this int to write the correct number of bytes from your buffer to your BinaryStream or whatever your using. You then keep copying bytes until you reach the end. It should look something like this:
FileStream fs = new FileStream(...);
BinaryStream bs = new BinaryStream();
byte[] buffer = new byte[1024];
int read = 0;
while(bs.Position < fs.Length)
{
read = fs.Read(buffer, 0, 1024);
bs.Write(buffer, 0, read);
}
fs.Close();
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
I have an application that I setup by adding a DataSet .xsd file to my project and then dragging tables from the Server Explorer data connections area. This automatically sets up the connection string in about a dozen places. Now I want the user to be able to point to the database they want to use, but I'm not sure where the connection needs to be updated.
The connection string exist in the main solution's
Properties\Settings.settings,<br />
Properties\Settings.designer.cs
In the data access layer project's
app.config<br />
Properties\Settings.settings,<br />
Properties\Settings.designer.cs
How would i update this value? From where (and how) should i read it when the app starts up, or if its being updated programatically would i have to save it to a custom file and read if from there?
|
|
|
|
|
How do I Create a webserver in C# with CGI Support for PHP?
Notice: It can support ASP.NET.
|
|
|
|
|
|
just create it?
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
neelchauhan wrote: How do I Create a webserver in C# with CGI Support for PHP?
Read the first post in the forum "How to get an answer to your question", pay attention to item #2.
led mike
|
|
|
|
|
|
Frst, work out when you need it by, then work out a budget. Finally post your estimates here and give the rest of us a laugh.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
See the first 3 articles mentioned on this[^] page.
/ravi
|
|
|
|
|
|
PInvokeStackImbalance was detected
Message: A call to PInvoke function 'XPExplorerBar!XPExplorerBar.NativeMethods::LoadBitmap
' has unbalanced the stack. This is likely because the managed PInvoke signature does
not match the unmanaged target signature. Check that the calling convention and
parameters of the PInvoke signature match the target unmanaged signature.
|
|
|
|
|
What is XPExplorerBar? A 3rd party control? If so, have you checked with them?
only two letters away from being an asset
|
|
|
|
|
Member 2117727 wrote: XpExploreBar in csharp
what is that ??
|
|
|
|
|
Seems like the product was against an older version of Windows that uses a different signature for LoadBitmap . Imho, the best you can do is contact the vendor and give them your OS details.
/ravi
|
|
|
|