"nomad" <d.*******@btinternet.comwrote in message
news:0d**********************************@k30g2000 hse.googlegroups.com...
I need to be able to check the logon credentials of a Windows XP
machine
Please clarify - you need to be able to check the credentials of a
machine,
not a user...?
If I log onto my machine in work (Windows XP) this authenticates with
active directory on our network and then logs me in. I would like to
be able to retrieve my login credentials, so I could then use these as
authentication to log directly onto my ASP.Net site.
Ah - so it's *your* credentials that you're looking for, not the
machine's... The reason I asked is that machines also have an account in
ActiveDirectory...
As my site will be on another network, I will then need to use these
logon credentials to authenticate with another server so I can then
retrieve what groups they have been placed in so I can limit where
they go in the site.
Understood. This shouldn't be too much of a problem, but you'll need to
supply a bit more information...
1) How are the two networks connected?
2) Do you have the same login (username and password) on both networks...?
3) Once you have been authenticated by AD on the first network, are you
considered to be similarly authenticated on the second network? I.e. is it
OK for the first network to tell the second network who you are?
After all that, retrieving the list of groups to which a user belongs is
fairly straightforward:
public static List<stringGetGroupsForUser(string pstrUser)
{
List<stringlstGroups = new List<string>();
using (DirectorySearcher objDS = new
DirectorySearcher("objectCategory=User"))
{
objDS.Filter = "(SAMAccountName=" + pstrUser + ")";
using (DirectoryEntry objUser = new
DirectoryEntry(objDS.FindOne().Path))
{
PropertyCollection colProperties = objUser.Properties;
PropertyValueCollection colPropertyValues =
colProperties["memberOf"];
foreach (string strGroup in colPropertyValues)
{
lstGroups.Add(GetSAMAccountName(strGroup).ToLower( ));
}
}
}
return lstGroups;
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net