도메인에서 사용자 이메일 검색

4485 단어 email

  
static public string GetEmailByUserID( string user_id, string pwd, string neededUser_ID)
{
string email = "" ;
DirectoryEntry entry
= new DirectoryEntry( " LDAP://zone1.scb.net " , user_id, pwd);
DirectorySearcher searcher
= new DirectorySearcher(entry);
searcher.Filter
= " (SAMAccountName= " + neededUser_ID + " ) " ;
searcher.PropertiesToLoad.Add(
" SAMAccountName " );
searcher.PropertiesToLoad.Add(
" mail " );
SearchResult result
= searcher.FindOne();
if (result != null )
{
if (result.Properties.Contains( " mail " ))
{
email
= ( string )result.Properties[ " mail " ][ 0 ];
}
}
if (entry != null )
{
entry.Dispose();
}
return email;
}

전환: http://www.cnblogs.com/catvi/archive/2011/03/31/2001053.html

좋은 웹페이지 즐겨찾기