|
Ok but with polling the client would have to make queries every 2 or 3 seconds to get close to real time
If it's not broken, fix it until it is
|
|
|
|
|
Yes, only as frequently as the user wants.
|
|
|
|
|
SignalR will be a better component for a chat application. I done a real-time time application with SignalR.. Its very interesting
|
|
|
|
|
Except is seems to be designed around ASP.Net. My usage will NOT be asp.Net
If it's not broken, fix it until it is
|
|
|
|
|
Kevin Marois wrote: My usage will NOT be asp.Net
So what language are you going to use?
|
|
|
|
|
Language? C#
ASP.Net is not a language. It's a Web Development platform
If it's not broken, fix it until it is
|
|
|
|
|
my bad.. forgot the forum title .. thought about PHP and Java .. apologies
|
|
|
|
|
Please can somebody help I'm struggling to display the thumbnailPhoto attribute in Active Directory on my gridview website.
Please find below the code and asp.net files
<%@ Page Title="AD USERS" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" Inherits="_Default" Codebehind="Default.aspx.cs" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<table cellpadding="4" cellspacing="4" width="90%" align="center" style="border: 1px solid Green;">
<tr>
<td>
<asp:GridView ID="grdViewAllADSUsers" runat="server" AllowPaging="True" CellPadding="4"
Width="98%" ForeColor="#333333" GridLines="None" OnPageIndexChanging="grdViewAllADSUsers_PageIndexChanging">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
<Columns>
<asp:ImageField DataImageUrlField="thumbnailPhoto" HeaderText="Image">
<ControlStyle Height="48px" Width="50px" />
</asp:ImageField>
<asp:BoundField DataField="displayName" HeaderText="Name" />
<asp:BoundField DataField="title" HeaderText="Job title" />
<asp:BoundField DataField="mail" HeaderText="E-mail" />
<asp:BoundField DataField="telephonenumber" HeaderText="Telephone Number" />
<asp:BoundField DataField="mobile" HeaderText="Mobile Number" />
<asp:BoundField DataField="facsimileTelephoneNumber" HeaderText="Fax Number" />
<asp:BoundField DataField="department" HeaderText="Department" />
<asp:BoundField DataField="manager" HeaderText="Manager" />
<asp:BoundField DataField="st" HeaderText="Car Registration" />
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</asp:Content>
C# code:
using System;
using System.Drawing;
using System.IO;
using System.Data.SqlTypes;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;
using System.Web.Security;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
GetAllADUsers();
}
public void GetAllADUsers()
{
try
{
DirectoryEntry myLdapConnection = createDirectoryEntry();
DirectorySearcher search = new DirectorySearcher(myLdapConnection);
search.Filter = "(&(objectClass=user)(objectCategory=person)(!sAMAccountType=805306370)(!userAccountControl:1.2.840.113556.1.4.803:=2)(description=Exchange User))";
search.SearchScope = SearchScope.Subtree;
search.PropertiesToLoad.Add("thumbnailPhoto");
search.PropertiesToLoad.Add("samaccountname");
search.PropertiesToLoad.Add("displayName");
search.PropertiesToLoad.Add("title");
search.PropertiesToLoad.Add("mail");
search.PropertiesToLoad.Add("telephoneNumber");
search.PropertiesToLoad.Add("mobile");
search.PropertiesToLoad.Add("facsimileTelephoneNumber");
search.PropertiesToLoad.Add("department");
search.PropertiesToLoad.Add("manager");
search.PropertiesToLoad.Add("st");
search.CacheResults = true;
SearchResultCollection allResults = search.FindAll();
DataTable resultsTable = new DataTable();
foreach (String colName in search.PropertiesToLoad)
{
if (colName == "thumbnailPhoto")
resultsTable.Columns.Add(colName, typeof(System.Drawing.Bitmap));
else
resultsTable.Columns.Add(colName,typeof(String));
}
resultsTable.Columns.Remove("ADsPath");
resultsTable.Columns.Remove("samaccountname");
foreach (SearchResult searchResult in allResults)
{
DataRow dr = resultsTable.NewRow();
if (searchResult.Properties.Contains("thumbnailPhoto"))
{
dr["thumbnailPhoto"] = byteArrayToImage((byte[])searchResult.Properties["thumbnailPhoto"][0]);
//byte[]staffPic = ((byte[])searchResult.Properties["thumbnailPhoto"][0]);
//Response.BinaryWrite(staffPic);
//Response.Flush();
//dr["thumbnailPhoto"] = GetUserPicture(searchResult.Properties["samaccountname"][0].ToString());
}
if (searchResult.Properties.Contains("displayName"))
dr["displayName"] = searchResult.Properties["displayName"][0].ToString();
if (searchResult.Properties.Contains("title"))
dr["title"] = searchResult.Properties["title"][0].ToString();
if (searchResult.Properties.Contains("mail"))
dr["mail"] = searchResult.Properties["mail"][0].ToString();
if (searchResult.Properties.Contains("telephoneNumber"))
dr["telephoneNumber"] = searchResult.Properties["telephoneNumber"][0].ToString();
if (searchResult.Properties.Contains("mobile"))
dr["mobile"] = searchResult.Properties["mobile"][0].ToString();
if (searchResult.Properties.Contains("facsimileTelephoneNumber"))
dr["facsimileTelephoneNumber"] = searchResult.Properties["facsimileTelephoneNumber"][0].ToString();
if (searchResult.Properties.Contains("department"))
dr["department"] = searchResult.Properties["department"][0].ToString();
if (searchResult.Properties.Contains("manager"))
{
String managerDN = searchResult.Properties["manager"][0].ToString();
String managerFQDN = "LDAP://" + managerDN;
DirectoryEntry manager = new DirectoryEntry(managerFQDN);
dr["manager"] = manager.Properties["displayName"][0].ToString();
}
if (searchResult.Properties.Contains("st"))
dr["st"] = searchResult.Properties["st"][0].ToString();
resultsTable.Rows.Add(dr);
}
grdViewAllADSUsers.DataSource = resultsTable;
grdViewAllADSUsers.ShowHeader = true;
grdViewAllADSUsers.AutoGenerateColumns = false;
grdViewAllADSUsers.DataBind();
}
catch (Exception)
{
}
}
public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
MemoryStream ms = new MemoryStream();
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
return ms.ToArray();
}
public System.Drawing.Image byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
return returnImage;
}
static System.Drawing.Image GetUserPicture(string userName)
{
using (DirectorySearcher dsSearcher = new DirectorySearcher())
{
dsSearcher.Filter = "(&(objectClass=user) (cn=" + userName + "))";
SearchResult result = dsSearcher.FindOne();
using (DirectoryEntry user = new DirectoryEntry(result.Path))
{
byte[] data = user.Properties["thumbnailPhoto"][0] as byte[];
if (data != null)
{
using (MemoryStream s = new MemoryStream(data))
{
return System.Drawing.Bitmap.FromStream(s);
}
}
return null;
}
}
}
static DirectoryEntry createDirectoryEntry()
{
// create and return new LDAP connection with desired settings
DirectoryEntry ldapConnection = new DirectoryEntry("my.domain");
ldapConnection.Path = "LDAP://my.domain/OU=Users,OU=Users & Computers,DC=my,DC=domain";
ldapConnection.AuthenticationType = AuthenticationTypes.Secure;
return ldapConnection;
}
protected void grdViewAllADSUsers_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grdViewAllADSUsers.PageIndex = e.NewPageIndex;
GetAllADUsers();
}
}
|
|
|
|
|
Can you narrow down where the specific issue is?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I think the problem is here:
if (searchResult.Properties.Contains("thumbnailPhoto"))
{
dr["thumbnailPhoto"] = byteArrayToImage((byte[])searchResult.Properties["thumbnailPhoto"][0]);
}
Or maybe in the asp code.
At the moment I get a table with every field populated how it is intended to be however the thumbnailPhoto field display a image of an X as though it isn't being pulled through.
If I run the command Response.BinaryWrite(staffPic); it displays the image on a complete blank screen.
What I'm trying to do is pull through the thumbnailPhoto pic into the datatable and then onto the gridview
|
|
|
|
|
Hi everybody,
On my Windows Mobile 6.5 application (developped in C# and DOTNET 3.5), I want use a VPN connection. My goals is the following: I connect my PDA on my PC via USB. Then, by clicking on a button of my WinCE application, I would send http request (with the object "HttpWebRequest" of C#) directly on PC (because VPN would be intalled on the PC).
I have already searched a solution of my problem but I have not found a solution.
Have you got an idea to do this?
Best regards
|
|
|
|
|
Wakonda wrote: Have you got an idea to do this? Google for instructions on how to set up VPN.
Wakonda wrote: directly on PC (because VPN would be intalled on the PC). ..if you're trying to talk to the server-VPN using TCP/IP from the mobile device, then that's not going to work. Try talking to a webserver on the PC.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i think you should write another application for your PC also which will receive requests from your windows phone and talk with VPN connection in pc and again send results to your phone but talking directly with windows phone is not a good and practical approach!
|
|
|
|
|
That could also be considered as opening a security hole in the VPN!
|
|
|
|
|
I am trying to move items up and down in generic list but not getting desired results If I have 5 items and and one their be 6 with order id's of 1 to 6 then when i move an item up one position via button click say item 6 it would become 5 and what was at 5 would become 6.
Can Someone help me out here please on the logic below?
ObservableCollection<CustomColumnsModel> columnsList = this.WizardData.ConcreteCustomColumnsProxy;
Extensions.MoveItemUp(columnsList, this.listView1.SelectedIndex);
List<CustomColumnsModel> forUpdate = new List<CustomColumnsModel>();
int offset = 0;
foreach (CustomColumnsModel item in this.listView1.Items)
{
if (this.listView1.SelectedItems.Contains(item))
{
offset++;
item.CustomColumnsOrder--;
}else
item.CustomColumnsOrder += offset;
}
|
|
|
|
|
Message Closed
modified 9-Sep-14 4:52am.
|
|
|
|
|
Not true, this is a perfectly valid question for this forum.
|
|
|
|
|
My point is that in order to get more answers it might be better to post it in the quick answers section.
Just look at the number of responses during almost 24 hours.
|
|
|
|
|
That's hardly a reason to repost it.
|
|
|
|
|
|
Given a List of Integers:
List<int> positions = new List<int>{1,2,3,4,5};
How would I code a loop to get the following results for a given number of iterations {n}:
n P1 P2
1 1 5
2 2 1
3 3 2
4 4 3
5 5 4
6 1 5
7 2 1
8 3 2
9 4 3
10 5 4
...
This should be simple but I have brain freeze.
I don't speak Idiot - please talk slowly and clearly
"I have sexdaily. I mean dyslexia. Fcuk!"
Driven to the arms of Heineken by the wife
|
|
|
|
|
p1 almost looks like n mod 5 + (5 iif prev result is 0)
p2 almost looks like p1 - 1 + (5 iif prev result is 0)
'g'
|
|
|
|
|
List<int> positions = new List<int> { 1, 2, 3, 4, 5 };
for (int n = 1, p1 = 0, p2 = 4; n <= 10; ++n, ++p1, ++p2)
{
p1 %= positions.Count;
p2 %= positions.Count;
Console.WriteLine("{0,2} {1} {2}", n, positions[p1], positions[p2]);
}
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
That works well and creates the list for n iterations.
How about finding the value of p1 and p2 when n is a defined number?
int n = 23;
p1 = ?
p2 = ?
...
I don't speak Idiot - please talk slowly and clearly
"I have sexdaily. I mean dyslexia. Fcuk!"
Driven to the arms of Heineken by the wife
|
|
|
|
|
If n starts with 1, then
p1 = (n-1) % positions.Count;
p2 = (positions.Count + n - 2) % positions.Count;
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|