tisdag, november 30, 2004
A case of mistaken identity
I've been fooling around with this small application that I need to develop for my job. It's an on-line NDA form of sorts that we're going to show to the user everytime she logs in until she agrees to it. We then update the Active Directory with the date she signed it.
We are going to use a web server to present the form which means that I need to get my IIS up and running as a development server (which I though I had but there's some funk with the connection to the AD). It also means that I need to grab the users credentials from the client operating system.
After looking around the web, mostly MSDN, I found the WindowsIdentity class. After some more fiddling around I got it to grab the name of the currently logged in user:
Console.WriteLine("Username: " + WindowsIdentity.GetCurrent().Name);
Now, what I get here is the actual username, in our case something rather cryptic, so I need to query the AD for the display name, just for looks though when we display the form to the user.
From my C# book I got an example that displays all the properties of an AD object, including users, but I can't modify it to my needs. The original code looks like this:
foreach (string name in properties.PropertyNames)
{
foreach (object o in properties[name])
{
Console.WriteLine(name + ": " + o);
}
}
and I want to use something like this:
Console.WriteLine("\n\nDisplayName: " + properties["displayName"]);
It doesn't work though and at the moment I'm too tired to keep at it. I'll get back to it tomorrow or Thursday.
Oh, and I found a new C# site; C# Help. Well, new to me atleast.
