| 
				                                 Charles Chen                				 
                					 
                     
                
                
                
                                 
                 
                
                
                                 
                                        Posts: 1 
                                                        Joined: 2017-10-25 
                                                
         | 
        
                
                
                C# Excel Shape.Fill.UserPicture not authenticating, but VBA Excel Shape.Fill.UserPicture does
 
 I am trying to set the fill on a shape to be an image.  The image is hosted on a different server.
 
 Excel.Shape shape = range.Worksheet.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, 0, 0, (float)(width), (float)(height));
 
 shape.Fill.UserPicture("http://[servernamehere]/file.jpg");
 
 The server that is hosting the image has LDAP authentication configured.
 
 When I run the VBA equivalent of this code, it makes two requests to for the image, the first is a 401, the second provides credentials and receives a 200.
 
 When I run the C# code, it only makes one failing request for the image.
 
 How do I get the C# code to also have the 2nd request attempt with credentials? Alternatively, how could I manually pass the credentials to the server?                 |   
                 
         | 
  
  
        | 
				                                 Andrei Smolin                				 
                					 					 
                
                
                
                 Add-in Express team                 
                 
                
                
                                 
                                        Posts: 19178 
                                                        Joined: 2006-05-11 
                                                
         | 
        
                
                
                Hello Charles, 
 
 I've enabled Windows authentication on my IIS (basic and anonymous authentication are disabled) and tested the issue. I cannot confirm it. Whether I use VBA (11:52:34) or C# (11:56:16), the server log contains two calls:
 
 2017-10-26 11:52:34 ::1 GET /iisstart.png - 80 - ::1 Mozilla/4.0+(...) - 401 2 5 0
 2017-10-26 11:52:34 ::1 GET /iisstart.png - 80 {domain}\{user} ::1 Mozilla/4.0+(...) - 304 0 0 0
 2017-10-26 11:56:16 ::1 GET /iisstart.png - 80 - ::1 Mozilla/4.0+(...) - 401 2 5 1
 2017-10-26 11:56:16 ::1 GET /iisstart.png - 80 {domain}\{user} ::1 Mozilla/4.0+(...) - 304 0 0 0
 
 Sub dfsdfgsdfg()
 Dim shp As Excel.Shape
 Set shp = ActiveSheet.Shapes.AddShape(Office.MsoAutoShapeType.msoShapeRectangle, 0, 0, 200, 200)
 shp.Fill.UserPicture "http://localhost/iisstart.png"
 End Sub
 
 private void adxRibbonButton1_OnClick(object sender, IRibbonControl control, bool pressed) {
     Excel.Shape shape = (ExcelApp.ActiveSheet as Excel.Worksheet).Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, 0, 0, (float)(200), (float)(200));
     shape.Fill.UserPicture("http://localhost/iisstart.png");
 }
 
 
 Andrei Smolin
 Add-in Express Team Leader                 |   
                 
         |