I have a webpart in sharepoint site. Webpart contains a textbox and an image. On click of that image I have called a function which access the WINNT and retrives the current user and displays it in the textbox.
This works prefectly in the server but not in the local machines. In the local machine when I open the site and click on the image, it is not retriveing the current user from the AD. It goes to the webpart maintenance page.
I feel that since the image is accessing the AD through the server this might be some security isses somewhere? any help on this would be gr8 ...
below is the function called on onclick of the image:
ThanksCode:void cisimg2_Click(object sender, ImageClickEventArgs e) { string name = GetFullName(System.Security.Principal.WindowsIdentity.GetCurrent().Name); textbox2.Text = name; } private string GetFullName(string strLogin) { string str = ""; // Parse the string to check if domain name is present. int idx = strLogin.IndexOf('\\'); if (idx == -1) { idx = strLogin.IndexOf('@'); } string strDomain; string strName; if (idx != -1) { strDomain = strLogin.Substring(0, idx); strName = strLogin.Substring(idx + 1); } else { strDomain = Environment.MachineName; strName = strLogin; } DirectoryEntry obDirEntry = null; obDirEntry = new DirectoryEntry("WinNT://" + strDomain + "/" + strName); System.DirectoryServices.PropertyCollection coll = obDirEntry.Properties; object obVal = coll["FullName"].Value; // object obVal = coll["mail"].Value; str = obVal.ToString(); //Trace.Write(ex.Message); return str; }




Reply With Quote