title: Can't retrieve EmployeeId from Active Directory
body: <p>My <code>GetActiveDirectory()</code> method is used to get data from Active Directory using the <code>SamAccountName</code>, and it's working but the problem is the <code>user.EmployeeId</code> return no sign of data.</p>
  
  <p>Why I can't receive the <code>EmployeeId</code> and how can I fix it?</p>
  
  <p>This is my codes:</p>
  
  <pre><code>public void GetActiveDirectory(DataTable DataStorage, string SamAccountName)
  {
          var domainContext = new PrincipalContext(
             ContextType.Domain, null, _ldapPath, _ldapUsername, _ldapPassword);
  
          var group = GroupPrincipal.FindByIdentity(domainContext, "Domain Users");
  
          if (group != null)
          {
              DataStorage.Columns.Add("SamAccountName");
              DataStorage.Columns.Add("Surname");
              DataStorage.Columns.Add("Guid");
              DataStorage.Columns.Add("Enabled");
              DataStorage.Columns.Add("GivenName");
              DataStorage.Columns.Add("EmailAddress");
              DataStorage.Columns.Add("SID");
              DataStorage.Columns.Add("DateCreated");
              DataStorage.Columns.Add("DateModified");
              DataStorage.Columns.Add("EmployeeNumber");
              DataStorage.AcceptChanges();
  
              foreach (var p in group.GetMembers(false))
              {
                  if(p.SamAccountName != null)
                  {
                      try
                      {
                          var user = UserPrincipal.FindByIdentity(
                              domainContext, IdentityType.SamAccountName, SamAccountName);
                          if (user != null)
                          {
                              var userDE = (DirectoryEntry)p.GetUnderlyingObject();
                              DateTime dateCreated = userDE.Properties["WhenCreated"].Value != null
                                  ? (DateTime)userDE.Properties["WhenCreated"].Value 
                                  : DateTime.MinValue;
                              DateTime dateModified = userDE.Properties["WhenChanged"].Value != null
                                  ? (DateTime)userDE.Properties["WhenChanged"].Value 
                                  : DateTime.MinValue;
                              DataRow dr = DataStorage.NewRow();
                              dr["SamAccountName"] = user.SamAccountName;
                              dr["Surname"] = user.Surname;
                              dr["Guid"] = user.Guid.ToString();
                              dr["Enabled"] = user.Enabled;
                              dr["GivenName"] = user.GivenName;
                              dr["EmailAddress"] = user.EmailAddress;
                              dr["SID"] = user.Sid.Value;
                              dr["EmployeeNumber"] = user.EmployeeId; //Always give an empty space or null.
                              dr["DateCreated"] = dateCreated;
                              dr["DateModified"] = dateModified;
                              DataStorage.Rows.Add(dr);
                              return;
                          }
                      }
                      catch { }
  
                      break;
                  }
              }
          }
      }
  </code></pre>