1
votes

I've issue with an asp page, when I run local from VS the page is fine but in the server not works. The is in IIS 7.0 as Application, the page show this errors:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Server names cannot contain a space character.

Source Error:

Line 96: ////Load Ad Info

Line 97: PrincipalContext ctx = new PrincipalContext(ContextType.Domain, domain,container);

Line 98: UserPrincipal user = UserPrincipal.FindByIdentity(ctx, userName);

The code is fine, follow:

    //Load Ad User
    string[] temp = Convert.ToString(WindowsIdentity.GetCurrent().Name).Split('\\');
    string domainuserName = temp[0] + "\\" + temp[1];
    string userName = temp[1];
    string domain = temp[0];
    lblUserAD.Text = Convert.ToString(userName).ToUpper();
    string container = @"DC=america,DC=ad,DC=flex,DC=com";


    ////Load Ad Info
    PrincipalContext ctx = new PrincipalContext(ContextType.Domain, domain,container);
    UserPrincipal user = UserPrincipal.FindByIdentity(ctx, userName);

    DirectoryEntry directoryEntry = user.GetUnderlyingObject() as DirectoryEntry;
1
did you ever get this resolved? - Simon Price
no, nothing done. - Alex Rosa

1 Answers

0
votes

For me it was resolved after changing idenity of Application pool from ApplicationPoolIdenity to LocalSystem