Advertisement

[x]
Attachment Details

Cannot find the network path to get user Full Name or User Groups under the Active Directory

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0
I need to import the full name of a user in the Active Directory. In an environment where the A.D. and the ISS are in the same server I had no problems.

There I had trouble moving the website to a system where the AD and the ISS are in separate machines, I am unable to get the FullName or any other information that must take from Active Directory.

Authentication (AD) is working because it is always necessary to add login and password to open the site. The problem lies when the page is open and need to extract information from the user.

Part of the code:

                obDirEntry = new DirectoryEntry("WinNT://" + strDomain + "/" + strName, "intranet", "intranet");
                System.DirectoryServices.PropertyCollection coll = obDirEntry.Properties;
                object obVal = coll["FullName"].Value;
                str = obVal.ToString();
                return str;

The variables 'strDomain' and 'strName' are ok, the problem lies in the path ("WinNt://...").

This is the error message:

System.Runtime.InteropServices.COMException (0x80070035): The network path was not found. at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.PropertyValueCollection.PopulateList() at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName) at System.DirectoryServices.PropertyCollection.get_Item(String propertyName) at Ipt.Service.UsuarioService.NomeCompleto(String strLogin)

fullcode:

 public string FullName(string strLogin)
        {
            string str = "";

            int idx = strLogin.IndexOf('\\');
            if (idx == -1)
            {
                idx = strLogin.IndexOf('@');
            }

            string strDomain;
            string strName;

            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, "intranet", "intranet");
                System.DirectoryServices.PropertyCollection coll = obDirEntry.Properties;
                object obVal = coll["FullName"].Value;
                str = obVal.ToString();
                return str;
            }
            catch (Exception ex)
            {
                str = "";
                return "Erro fullname: " + ex + " --- STRDOMAIN: " + strDomain + "--- STRNAME: " + strName;
            }
        }
Related Solutions
Related Solutions
 
Loading Advertisement...
 

Rank: Genius

Expert Comment by Netman66:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Accepted Solution by znotte:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
Loading Advertisement...
20080924-EE-VQP-40 / EE_QW_2_20070628