Active Directory Usage In Web  
Author Message
Katakulli





PostPosted: Visual C# General, Active Directory Usage In Web Top

Hi,

I have found samples of querying user information from active directory and developed a small code. But when it is time to call it from a Web based class it presented an error with System.DirectoryServices . I searched the web and it is said that I should have used System.Web. namespace but I couldn't find any samples showing how to do it.

any help will be appriciated.....

Regards

I am trying to get user's web adress:

String operationSoftwareUser = null;

try

{

DirectoryEntry entry = new

DirectoryEntry("LDAP://server.domain.com");

DirectorySearcher search = new DirectorySearcher(entry);

search.Filter = String.Format("(SAMAccountName={0})", operatingSystemUser);

search.PropertiesToLoad.Add("url");

SearchResult result = search.FindOne();

if (result != null)

{

foreach (string key in result.Properties.PropertyNames)

{

if (key = "url")

{

String urlAddress = null;

foreach (Object propValue in result.Properties[key])

{

urlAddress = (String)propValue;

if (urlAddress.Substring(0, 14) == "OTHERSYSTEMUSER")

{

operationSoftwareUser = urlAddress.Substring(14);

}

}

}

}

}




Visual C#6