The S.DS.AM namespace was introduced in .NET 3.5 and, unfortunately, there is no version 2.0.
You can query the current Windows user in an ASP.NET application using WindowsIdentity.GetCurrent (). Name - this gives you DOMAIN \ UserName.
You will then need to search the user in AD for that user with a DirectorySearcher object to find the appropriate DirectoryEntry. This will give you all the pieces of this user.
string currentUser = WindowsIdentity.GetCurrent().Name; string[] domainUserName = currentUser.Split('\\'); string justUserName = domainUserName[1]; DirectoryEntry searchRoot = new DirectoryEntry("LDAP://dc=(yourcompany),dc=com"); DirectorySearcher ds = new DirectorySearcher(searchRoot); ds.SearchScope = SearchScope.Subtree; ds.PropertiesToLoad.Add("sn"); ds.PropertiesToLoad.Add("givenName"); ds.Filter = string.Format("(&(objectCategory=person)(samAccountName={0}))", justUserName); SearchResult sr = ds.FindOne(); if (sr != null) { string firstName = sr.Properties["givenName"][0].ToString(); string lastName = sr.Properties["sn"][0].ToString(); }
This is a bit complicated and related to .NET 2.0 - cannot change this: - (
Mark
source share