Last post Aug 03, 2011 10:01 AM by gww
None
0 Points
4 Posts
Aug 02, 2011 03:51 PM|pattyk13|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
Participant
1062 Points
428 Posts
Aug 03, 2011 10:01 AM|gww|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.
None
0 Points
4 Posts
Return ALL from Global Address List
Aug 02, 2011 03:51 PM|pattyk13|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
Participant
1062 Points
428 Posts
Re: Return ALL from Global Address List
Aug 03, 2011 10:01 AM|gww|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.