|
-
May 13th, 2008, 04:43 AM
#1
Thread Starter
Lively Member
Issue in Accessing the AD through Server
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:
Code:
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;
}
Thanks
Last edited by mendhak; May 13th, 2008 at 02:32 PM.
-
May 13th, 2008, 02:31 PM
#2
Re: Issue in Accessing the AD through Server
Please use [code] tags to surround your code to make it more readable.
On your local machine, do you have windows authentication checked in IIS for that application?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|