Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 03, 2011 02:01 PM by gww
Member
6 Points
5 Posts
Aug 02, 2011 07:51 PM|LINK
I need to know how to get everyone in the Global Address List (GAL), not just those in our domain. We have many external users added. Here is my code..
DirectorySearcher search = new DirectorySearcher();
String name = txtLastName.Text;
search.Filter = "(& (&(mailnickname=*)(showInAddressBook=CN=Default Global Address List,CN=All Global Address Lists," + "CN=Address Lists Container,CN=Company Name,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=corp,DC=root))" + "(|(cn=*" + name + "*)" + "(|(givenName=*"+ name + "*)" + "(sn=*" + name + "*)" + "(|(sAMAccountName=*" + name + "*)))))";
search.SearchScope = System.DirectoryServices.SearchScope.Subtree; search.Sort.Direction = System.DirectoryServices.SortDirection.Ascending;
search.PropertiesToLoad.Add("cn");
search.PropertiesToLoad.Add("SAMAccountName");
search.PropertiesToLoad.Add("mail");
foreach (SearchResult sr in results)
{
for (Int32 i = 0; i < sr.Properties["mail"].Count; i++)
Email = sr.Properties["mail"][i].ToString();
if (Email == txtEmailAddress.Text)
AccountName = sr.Properties["SAMAccountName"].ToString();
}
Please help!!!
address
Contributor
2143 Points
458 Posts
Aug 03, 2011 02:01 PM|LINK
You just need to connect to the global ldap server and run the search from there. You sysadmin should be able to tell you what the address is.
pattyk13
Member
6 Points
5 Posts
Return ALL from Global Address List
Aug 02, 2011 07:51 PM|LINK
I need to know how to get everyone in the Global Address List (GAL), not just those in our domain. We have many external users added. Here is my code..
DirectorySearcher search = new DirectorySearcher();
String name = txtLastName.Text;
search.Filter = "(& (&(mailnickname=*)(showInAddressBook=CN=Default Global Address List,CN=All Global Address Lists,"
+ "CN=Address Lists Container,CN=Company Name,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=corp,DC=root))"
+ "(|(cn=*" + name + "*)"
+ "(|(givenName=*"+ name + "*)"
+ "(sn=*" + name + "*)"
+ "(|(sAMAccountName=*" + name + "*)))))";
search.SearchScope = System.DirectoryServices.SearchScope.Subtree;
search.Sort.Direction = System.DirectoryServices.SortDirection.Ascending;
search.PropertiesToLoad.Add("cn");
search.PropertiesToLoad.Add("SAMAccountName");
search.PropertiesToLoad.Add("mail");
foreach (SearchResult sr in results)
{
for (Int32 i = 0; i < sr.Properties["mail"].Count; i++)
{
Email = sr.Properties["mail"][i].ToString();
if (Email == txtEmailAddress.Text)
AccountName = sr.Properties["SAMAccountName"].ToString();
}
}
Please help!!!
address
gww
Contributor
2143 Points
458 Posts
Re: Return ALL from Global Address List
Aug 03, 2011 02:01 PM|LINK
You just need to connect to the global ldap server and run the search from there. You sysadmin should be able to tell you what the address is.