Loading ...
Sorry, an error occurred while loading the content.

Re: [ADSI-DirSrv] Need help in retrieving properties using Search object

Expand Messages
  • sudeep raj
    Hi Vinod Could you be specific what you mean by domain users of AD. By the code i have given you can get all the user details. Please be a bit specific. Could
    Message 1 of 4 , Jul 1, 2007
    • 0 Attachment
      Hi Vinod
      Could you be specific what you mean by domain users of AD. By the code i have given you can get all the user details. Please be a bit specific.
      Could you tell me what is domainSync. I havent herd the term may be I know it.
      If you get any idea bt the do let me know
      Thanx in advance.

      vinod vjn <vinodjnair@...> wrote:
      Thanks sudeep for your help.

      I would also like to know the how can we get the domain users from AD. Also,
      please let me know if you any idea on DirectorySynchronization in .net 2.0.

      On 6/27/07, sudeep raj <sudeep347@...> wrote:
      >
      > Hi Vinod
      > You can do what I have done to retrieve the values.
      >
      > Here is the code:
      >
      >
      > DirectoryEntry entry = GetDirectoryEntry(); //GetDirectoryEntry() is
      > another function.
      > //String account = userAccount.Replace(@"Domain\", "");
      >
      > try
      > {
      > DirectorySearcher search = new DirectorySearcher(entry);
      > search.Filter = "(SAMAccountName=" + userAccount + ")";
      > string[] props = { "sn", "title", "physicalDeliveryOfficeName",
      > "telephonenumber", "givenName", "department", "homePostalAddress", "mail",
      > "samaccountname", "displayName","mobile" };
      > foreach(string prop in props)
      > {
      > search.PropertiesToLoad.Add(prop);
      > }
      > SearchResult result = search.FindOne();
      > if (result != null)
      > {
      > if (result.Properties.Contains("sn"))
      > TxbLname.Text = RetrieveReplace(result.Properties["sn"][0].ToString());
      > else
      > TxbLname.Text = "";
      > if (result.Properties.Contains("givenName"))
      > TxbFname.Text = RetrieveReplace(result.Properties
      > ["givenName"][0].ToString());
      > else
      > TxbFname.Text = "";
      > if (result.Properties.Contains("title"))
      > DDLCader.SelectedValue = result.Properties["title"][0].ToString();
      > else
      > DDLDept.SelectedIndex = 0;
      > if (result.Properties.Contains("physicalDeliveryOfficeName"))
      > DDLLoc.SelectedValue = RetrieveReplace(result.Properties
      > ["physicalDeliveryOfficeName"][0].ToString());
      > else
      > DDLDept.SelectedIndex = 0;
      > if (result.Properties.Contains("telephonenumber"))
      > {
      > DDLphno.SelectedValue = (result.Properties
      > ["telephonenumber"][0].ToString()).Substring(0,4);
      > TxbPhno.Text = RetrieveReplace((result.Properties
      > ["telephonenumber"][0].ToString()).Substring(4,4));
      > }
      > if (result.Properties.Contains("department"))
      > DDLDept.SelectedValue = result.Properties["department"][0].ToString();
      > else
      > DDLDept.SelectedIndex = 0;
      > if (result.Properties.Contains("homePostalAddress"))
      > TxbSchool.Text = RetrieveReplace(result.Properties
      > ["homePostalAddress"][0].ToString());
      > else
      > TxbSchool.Text = "";
      > if (result.Properties.Contains("mail"))
      > TxbMail.Text = result.Properties["
      > mail][0].ToString().Replace(@...<mail%22%5D%5B0%5D.ToString%28%29.Replace%28%22%40lntinfotech.com>
      > ","");
      > else
      > TxbMail.Text = "";
      > if (result.Properties.Contains("mobile"))
      > TxbMob.Text = RetrieveReplace(result.Properties["mobile"][0].ToString());
      > else
      > TxbMob.Text = "";
      > }
      > else
      > {
      > MessageBox("sorry");
      > }
      > }
      > catch (Exception ex)
      > {
      > string debug = ex.Message;
      > }
      > }
      >
      >
      > Vinod J Nair <vinodjnair@... <vinodjnair%40gmail.com>> wrote:
      > Hi,
      >
      > I am able to retrieve the samAccountName, ObjectGUID properties of AD
      > users using the Search object. But I would like to know how can i
      > retrieve givenName(first name), sn(last name), extendedattributes from
      > active directory using the Search object.
      >
      > I am using the search criteria for filtering users
      > "(&(ObjectCategory=Person)(ObjectClass=User))". I would like to know
      > how can i get only domain user accounts from AD (excluding guest user
      > accounts and other local accounts).
      >
      > Please reply as soon as possible.
      >
      > Thanks,
      > Vinod
      >
      > ---------------------------------
      > Got a little couch potato?
      > Check out fun summer activities for kids.
      >
      > [Non-text portions of this message have been removed]
      >
      >
      >

      [Non-text portions of this message have been removed]






      ---------------------------------
      Looking for earth-friendly autos?
      Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.