1: private void GetData()
2: {3: try
4: {5: string str;
6: str = "LDAP://" + this.GetDefaultNamingContext();
7: 8: DirectoryEntry de = new DirectoryEntry(str, SvrAdminID, SvrAdminPass);
9: DirectorySearcher ds = new DirectorySearcher(de);
10: string[] retStr = null;
11: 12: ds.Filter = "(&(objectClass=user)(objectCategory=person)(sAMAccountName=" + pUserID + "))";
13: 14: SearchResultCollection src = ds.FindAll(); 15: 16: if (src.Count > 0)
17: {18: for (int i = 0; i < src.Count; i++)
19: {20: retStr = new string[src.Count];
21: 22: if (src[i].GetDirectoryEntry().Properties["displayname"].Value != null)
23: {24: this.UserName.Text = src[i].GetDirectoryEntry().Properties["displayname"][0].ToString();
25: } 26: 27: this.UserNum.Text = pUserID;
28: 29: 30: if (src[i].GetDirectoryEntry().Properties["title"].Value != null)
31: {32: this.TitleRole.Text = src[i].GetDirectoryEntry().Properties["title"][0].ToString();
33: } 34: 35: if(src[i].GetDirectoryEntry().Properties["Department"].Value != null)
36: {37: this.DeptName.Text = src[i].GetDirectoryEntry().Properties["Department"][0].ToString();
38: } 39: 40: if (src[i].GetDirectoryEntry().Properties["telephoneNumber"].Value != null)
41: {42: this.OfficeTelNum.Text = src[i].GetDirectoryEntry().Properties["telephoneNumber"][0].ToString();
43: }44: if (src[i].GetDirectoryEntry().Properties["facsimileTelephoneNumber"].Value != null)
45: {46: this.FaxNum.Text = src[i].GetDirectoryEntry().Properties["facsimileTelephoneNumber"][0].ToString();
47: } 48: 49: if (src[i].GetDirectoryEntry().Properties["homePhone"].Value != null)
50: {51: this.HomeTelNum.Text = src[i].GetDirectoryEntry().Properties["homePhone"][0].ToString();
52: } 53: 54: if (src[i].GetDirectoryEntry().Properties["mobile"].Value != null)
55: {56: this.MobileNum.Text = src[i].GetDirectoryEntry().Properties["mobile"][0].ToString();
57: } 58: 59: if (src[i].GetDirectoryEntry().Properties["mail"].Value != null)
60: {61: this.Email.Text = src[i].GetDirectoryEntry().Properties["mail"][0].ToString();
62: } 63: 64: if (src[i].GetDirectoryEntry().Properties["description"].Value != null)
65: {66: this.Business.Value = src[i].GetDirectoryEntry().Properties["description"][0].ToString();
67: } 68: 69: if (src[i].GetDirectoryEntry().Properties["distinguishedName"].Value != null)
70: {71: this.HidCN.Value = src[i].GetDirectoryEntry().Properties["distinguishedName"][0].ToString();
72: } 73: 74: } 75: 76: } 77: 78: }79: catch (Exception ex)
80: {81: Response.Write("Error : " + ex.Message.ToString());
82: LogFile.LogWrite("GroupwareError", "Error Message: " + ex.Message.ToString());
83: LogFile.LogWrite("GroupwareError", "Error StackTrace: " + ex.StackTrace.ToString());
84: LogFile.LogWrite("GroupwareError", "Error Source: " + ex.Source.ToString());
85: } 86: } 87: 88: 89: private int UserModify(string strOfficeTelNum, string strFaxNum, string strHomeTelNum, string strMobileNum, string strBusiness)
90: { 91: 92: int tmpBool = 1;
93: 94: string str = "LDAP://" + this.HidCN.Value;
95: 96: 97: DirectoryEntry objADAM = new DirectoryEntry(str, this.SvrAdminID, this.SvrAdminPass);
98: try
99: { 100: objADAM.RefreshCache(); 101: 102: if (strOfficeTelNum != "")
103: {104: objADAM.Properties["telephoneNumber"].Value = strOfficeTelNum;
105: }106: if (strFaxNum != "")
107: {108: objADAM.Properties["facsimileTelephoneNumber"].Value = strFaxNum;
109: }110: if (strHomeTelNum != "")
111: {112: objADAM.Properties["homePhone"].Value = strHomeTelNum;
113: }114: if (strMobileNum != "")
115: {116: objADAM.Properties["mobile"].Value = strMobileNum;
117: }118: if (strBusiness != "")
119: {120: objADAM.Properties["description"].Value = strBusiness;
121: } 122: 123: tmpBool = 1; 124: 125: objADAM.CommitChanges(); 126: objADAM.Close(); 127: objADAM.Dispose(); 128: 129: 130: }131: catch (Exception exception)
132: { 133: tmpBool = -1;134: LogFile.LogWrite("ADLog", "OrgAD UserModify exception.Message:" + exception.Message.ToString());
135: LogFile.LogWrite("ADLog", "OrgAD UserModify exception.StackTrace:" + exception.StackTrace.ToString());
136: LogFile.LogWrite("ADLog", "OrgAD UserModify InnerException.StackTrace:" + exception.InnerException.ToString());
137: throw exception;
138: 139: }140: finally
141: { 142: objADAM.Close(); 143: objADAM.Dispose(); 144: }145: return tmpBool;
146: } 147: 148: public string GetDefaultNamingContext()
149: {150: string str = "";
151: DirectoryEntry entry = new DirectoryEntry("LDAP://RootDSE");
152: try
153: {154: if (entry != null)
155: {156: str = entry.Properties["defaultNamingContext"].Value.ToString();
157: entry.Close(); 158: entry.Dispose();159: return str;
160: }161: return null;
162: }163: catch (Exception exception)
164: {165: LogFile.LogWrite("ADLog", "OrgAD GetDefaultNamingContext Log:" + exception.Message.ToString());
166: return null;
167: } 168: }'Lecture > C#' 카테고리의 다른 글
| partial Class (0) | 2011/02/22 |
|---|---|
| AD 사용자 정보 가져오기 및 수정하기 (1) | 2010/07/08 |
| Exchange CAS 서버의 EWS 웹서비스 접근시 주의 사항 (0) | 2010/04/15 |
| C#, VBScript, MSSQL, Javascript 에서의 base64 인코딩, 디코딩 (0) | 2009/12/11 |
| Head First C# A Day at The Races 소스 (0) | 2009/10/09 |
| 간단한 윈폼 DataGridView (0) | 2009/09/28 |
-
Jordan Spizikes 2012/01/05 11:36
적당한 쌍을 찾는 일이 정말 많은 시간과 노력을 수반하지 않습니다. 이것에 비추어 볼 때, 발에 가장 적합한 스포츠 신발을 선택하기 위해 고려해야 할 4 단계가 있습니다.

Prev

Rss Feed