Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 22, 2011 07:37 PM by ignatandrei
Member
4 Points
12 Posts
Jul 22, 2011 07:32 PM|LINK
Hi,
I am running this method from my Visual Studio 2010 application to retreive AD user names without any issues (it is returning the ADSI user's full name) :
public static string GetFullName(string strLogin) { string str = ""; string strDomain; string strName;
// Parse the string to check if domain name is present. int idx = strLogin.IndexOf('\\'); if (idx == -1) { idx = strLogin.IndexOf('@'); }
if (idx != -1) { strDomain = strLogin.Substring(0, idx); strName = strLogin.Substring(idx + 1); } else { strDomain = Environment.MachineName; strName = strLogin; }
DirectoryEntry obDirEntry = null; try { obDirEntry = new DirectoryEntry("WinNT://" + strDomain + "/" + strName); System.DirectoryServices.PropertyCollection coll = obDirEntry.Properties; object obVal = coll["FullName"].Value; str = obVal.ToString(); } catch (Exception ex) { str = ex.Message; } return str; }
I have setup IIS on the same pc from which I am running Visual Studio so I am able to run my application from http://localhost.
The application runs fine except that I am not able to read from ADSI even if the IIS is sitting on the same pc.
The error is (in french) : Le chemin réseau n'a pas été trouvé.
Which is probably something like this in english : The network path was not found.
I am probably missing a setting but I've spent too much time now to try to get it to work... Can anyone help me resolving this?
Thanks!!
All-Star
134983 Points
21638 Posts
Moderator
MVP
Jul 22, 2011 07:37 PM|LINK
for sure is the line
jepaulin obDirEntry = new DirectoryEntry("WinNT://" + strDomain + "/" + strName);
Please talk with your sysadmin if the path is correct
jepaulin
Member
4 Points
12 Posts
Unable to get ADSI info from localhost site
Jul 22, 2011 07:32 PM|LINK
Hi,
I am running this method from my Visual Studio 2010 application to retreive AD user names without any issues (it is returning the ADSI user's full name) :
public static string GetFullName(string strLogin)
{
string str = "";
string strDomain;
string strName;
// Parse the string to check if domain name is present.
int idx = strLogin.IndexOf('\\');
if (idx == -1)
{
idx = strLogin.IndexOf('@');
}
if (idx != -1)
{
strDomain = strLogin.Substring(0, idx);
strName = strLogin.Substring(idx + 1);
}
else
{
strDomain = Environment.MachineName;
strName = strLogin;
}
DirectoryEntry obDirEntry = null;
try
{
obDirEntry = new DirectoryEntry("WinNT://" + strDomain + "/" + strName);
System.DirectoryServices.PropertyCollection coll = obDirEntry.Properties;
object obVal = coll["FullName"].Value;
str = obVal.ToString();
}
catch (Exception ex)
{
str = ex.Message;
}
return str;
}
I have setup IIS on the same pc from which I am running Visual Studio so I am able to run my application from http://localhost.
The application runs fine except that I am not able to read from ADSI even if the IIS is sitting on the same pc.
The error is (in french) : Le chemin réseau n'a pas été trouvé.
Which is probably something like this in english : The network path was not found.
I am probably missing a setting but I've spent too much time now to try to get it to work... Can anyone help me resolving this?
Thanks!!
ignatandrei
All-Star
134983 Points
21638 Posts
Moderator
MVP
Re: Unable to get ADSI info from localhost site
Jul 22, 2011 07:37 PM|LINK
for sure is the line
Please talk with your sysadmin if the path is correct