15,896,118 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by shan1395 (Top 105 by date)
shan1395
17-Mar-12 6:35am
View
Thanks Vijay,true that will help me but am using pattern in my code do you noticed in my code ?
shan1395
8-Mar-12 23:31pm
View
how HTML going to help me ?
shan1395
8-Mar-12 22:13pm
View
Hi Ganesan, can you please let me know how to check the application Id rights ?
shan1395
8-Mar-12 22:04pm
View
Am thinking for an alternative and ugly method to loop thru each sub directory to create
shan1395
8-Mar-12 22:03pm
View
Yes i do have WSFTP client
shan1395
8-Mar-12 22:01pm
View
I couldn't able to post the code here,it automatically change in to char
shan1395
8-Mar-12 22:00pm
View
Deleted
"<"
shan1395
8-Mar-12 22:00pm
View
hi SA,
this is the value i mean code for the char <
shan1395
8-Mar-12 21:31pm
View
Thanks GanesanSenthilvel, i tried what you suggested but still am getting the spl char in the xml file.its freak me out now.
shan1395
8-Mar-12 20:43pm
View
even i tried with full control,still having the same issue
shan1395
8-Mar-12 20:38pm
View
thanks GanesanSenthilvel,if i use path1:"ftp://1.1.1.1/server01", then my code creates Server01 dir but when i use the whole path to create sub dir then throws error. i checked with admin i have read/write access for that.
shan1395
4-Mar-12 23:08pm
View
Thanks a lot Bjorn Ranft.
shan1395
30-Jan-12 18:53pm
View
wow that's mind blowing...
shan1395
30-Jan-12 17:59pm
View
Thanks a lot Sriram ,Even i was thinking to write a windows to pool the table but i felt CLR is better than open DB connection quite often thru interval time period.please correct me if am wrong.Am not implementing any windows service,changed the design like CLR Trigger --->WCF--->FTPWebREquest-->FTP. FTPWebRequest is inside the WCF so,i don't need windows service in the present scenario.
shan1395
23-Jan-12 20:48pm
View
Thanks Sriram, the only thing its hesitate me here is,if clr trigger send the file name and location to WCF then my FTP process start there,in some reason it takes long time or any failure to download the file thru FTP at the same time the CLR trigger the next record then its gonna queue isn't. for avoid that i thought write it in a text file then use window service to go and read the filename and location ,download the file from FTP then go to the next record.Anyway am update the status in DB for each success full download.
shan1395
19-Jan-12 5:23am
View
Thanks youssef_123, before i was create an assembly, already enabled CLR and the rest you mentioned but some how it was throwing error,so i deleted all the assemblies and change the machine.config and re created it.This time it created assembly with out hassle anyway thanks for your help.Am using CLR in my WCF.
shan1395
25-Aug-11 23:54pm
View
i has a value in it.
shan1395
19-Aug-11 11:19am
View
xdoc.SelectSingleNode("//*[local-name()='identifier']");
shan1395
17-Aug-11 1:14am
View
yeah i changed xdoc
shan1395
17-Aug-11 0:49am
View
this xpath make me crazy,no luck..still i got
Object reference not set to an instance of an object.
shan1395
17-Aug-11 0:10am
View
even i tried your approach too
XmlNode nlst = xdoc.SelectSingleNode("//identifier");
string value= nlst.Value;
nlst have null value. am not sure what am missing here
shan1395
16-Aug-11 3:00am
View
Thanks Senthil
finally i used this query to solve the problem
//Identifier[text() = \"BatchProcessed\"]
shan1395
16-Aug-11 2:06am
View
i tried something different way ,some how my count always "0" am not sure why
int count = oDoc.SelectNodes("//Header[.//Identifier='BatchProcessed']").Count;
some one guide me on the right way.
shan1395
16-Aug-11 2:06am
View
some how my count always "0" am not sure why
int count = oDoc.SelectNodes("//Header[.//Identifier='BatchProcessed']").Count;
some one guide me on the right way.
shan1395
11-Aug-11 3:57am
View
namespace DataGridPaging
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}
//Main method
static void Main()
{
Application.Run(new Login());
}
//Login button click validation
private void btnSubmit_Click(object sender, EventArgs e)
{
string username=txtUserName.Text.ToString();
string pass = txtPass.Text.ToString();
if (username == "test")
{
this.Close();
//Login successful then navigate to Form2.
DbNavigate.frmDataGridPaging form = new DbNavigate.frmDataGridPaging();
form.ShowDialog();
}
else
{
MessageBox.Show("Login Failed");
}
}
shan1395
11-Aug-11 3:56am
View
Nope am not disposing any where..its extremely simple code i have it
namespace DataGridPaging
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}
//Main method
static void Main()
{
Application.Run(new Login());
}
//Login button click validation
private void btnSubmit_Click(object sender, EventArgs e)
{
string username=txtUserName.Text.ToString();
string pass = txtPass.Text.ToString();
if (username == "test")
{
Login logform = new Login();
//Login successful then navigate to Form2.
DbNavigate.frmDataGridPaging form = new DbNavigate.frmDataGridPaging();
form.ShowDialog();
}
else
{
MessageBox.Show("Login Failed");
}
}
shan1395
11-Aug-11 3:41am
View
even i tried like this
this.Close();
//Login successful then navigate to Form2.
DbNavigate.frmDataGridPaging form = new DbNavigate.frmDataGridPaging();
form.ShowDialog(this);
it throws exception below
Cannot access a disposed object.
Object name: 'Login'.
shan1395
10-Aug-11 23:21pm
View
Okie finally wrote the code
void ErrGrid_CellClick(object sender, DataGridViewCellEventArgs e)
{
// Ignore clicks that are not on button cells.
if (e.RowIndex < 0 || e.ColumnIndex != ErrGrid.Columns["MessageId"].Index) return;
//// Retrieve the Row Index
string RowId = ErrGrid[0, e.RowIndex].Value.ToString();
//// convert string to Interger
int RowIndex;
int.TryParse(RowId, out RowIndex);
//Retrive the Error Queue Message for that particular Row Index
string MesId = ErrGrid.Rows[RowIndex].Cells["Queue"].Value.ToString();
MessageBox.Show(MesId);
}
I need small help here,rather than using messagebox here is this anyway i can open new window (pop up) to display the message
shan1395
10-Aug-11 22:51pm
View
thanks Christian Graus,
this line
if (e.RowIndex < 0 || e.ColumnIndex != ErrGrid.Columns["MessageId"].Index) return; will do the job if the hyperlink column clicked or not.
i will try to parse then.
i want to try one more thing here,how to popup the window when the hyperlink column clicked ?
shan1395
10-Aug-11 22:25pm
View
void ErrGrid_CellClick(object sender, DataGridViewCellEventArgs e)
{
// Ignore clicks that are not on button cells.
if (e.RowIndex < 0 || e.ColumnIndex != ErrGrid.Columns["MessageId"].Index) return;
//// Retrieve the RowId
int RowId = (Int32)ErrGrid[0, e.RowIndex].Value;
Am getting an error "pecified cast is not valid".
Any help please
shan1395
10-Aug-11 22:23pm
View
ErrGrid.CellClick += new DataGridViewCellEventHandler(ErrGrid_CellClick);
This event handler triggers any cell will click,how can i choose only it triggers when my hyperlink column cell clicked
shan1395
10-Aug-11 21:39pm
View
i used enumerator to solve this problem
MessageEnumerator Enum = mq.GetMessageEnumerator2();
while (Enum.MoveNext())
{
mes = Enum.Current;
mes.Formatter = new XmlMessageFormatter(new string[] { "System.String,mscorlib" });
m = mes.Body.ToString();
}
shan1395
10-Aug-11 3:13am
View
Thanks Thomas, i just followed this example
ErrGrid.Rows[n].Cells[5].Value = m.ToString();
shan1395
4-Aug-11 0:45am
View
Awesome Prerak patel .
shan1395
4-Aug-11 0:29am
View
i was exactly follow you here is the modified code
listView1.Columns.Add("No");
listView1.Columns.Add("MSMQ message");
listView1.Items.Add(new ListViewItem(new string[] { "1", m.ToString() }));
I suppose to get like
No MSMQ Message
1 testMessage
But wat am getting here in my listview is
1 1 1 1 1
it has 5 MSMQ message but it just populated the constant value.
Eventhough it populated in column it should be
NO MSMQ Message
1 TestMessage1
1 TestMessage2
1 TestMessage3
1 TestMessage4
shan1395
4-Aug-11 0:11am
View
Thanks Prerak,
But i want to display my items like
column name : ID Column Name : Message
1 Sample Message (i will get this from m.tostring())
as per your input am not getting the column name and adding the rows vice
shan1395
3-Aug-11 1:24am
View
Find this code in codeproject ,in a realistic situation its really tough to write a code with out a help from code project ;)
the below code
private void btnRcv_Click(object sender, System.EventArgs e)
{
System.Messaging.Message mes;
string m;
try
{
mes = mq.Receive(new TimeSpan(0, 0, 3));
mes.Formatter = new XmlMessageFormatter(new String[] {"System.String,mscorlib"});
m = mes.Body.ToString();
MsgBox.Items.Add(m.ToString());
}
catch
{
m = "No Message";
}
}
Okie what am trying to do here is,one single click i want to populate all the receive messages in to MsgBox.Items.Add(m.ToString());
If you see the code there is no loop used and am wondering why it is delete the queue ? once its retrieved.
Some one help me to write a for each loop for all the mewssages
shan1395
26-Jul-11 3:50am
View
yeah am using winforms
shan1395
26-Jul-11 2:57am
View
sorry to bother you again how to reffer those classes in my code please ?
and i have no idea what is "this.page"
shan1395
26-Jul-11 2:28am
View
thanks a lot for your help Prerak,can you please guide me what am doing is right based on your URL.
this is the only code i have to call in Button click
private void ExportLinkButton_Click(object sender, System.EventArgs e)
{
string strTitle = �put the grid title here�;
new DataGridExcelExporter(this.YourGridName , this.Page).Export(strTitle);
}
shan1395
12-Jul-11 21:13pm
View
Hi Neeraj,
Am hosting it on Windows Service.
shan1395
8-Jul-11 0:11am
View
Thanks Ramalinga
shan1395
4-Jul-11 1:03am
View
Thanks Amit,that works like a charm
shan1395
4-Jul-11 0:05am
View
Let me try and let you know the output
shan1395
3-Jul-11 23:41pm
View
Hi Amit,
Thanks for your help, here is my code
try
{
railMsg.Formatter = new XmlMessageFormatter(new Type[] { typeof(XmlElement) });
railMsg = externalQueue.Receive();
}
catch (Exception e)
{
logMessage("Error receiving message from queue: "+ e.Message);
}
shan1395
30-Jun-11 2:13am
View
hi Jaans,
thanks that's suppose to post in solution,even i figured out am missing in the string.
Thanks
shan1395
28-Jun-11 22:52pm
View
shan1395
28-Jun-11 22:51pm
View
errstring suppose to be my xmlvalue.i pasted that code but its not showing here
shan1395
28-Jun-11 22:50pm
View
Hi balaji,
Just modified the code can you please let me am doing right
string errString = "";
string errString = "";
string correctString = errString.Replace("", " ");
if (correctString.Trim().Length>1)
{
update database
}
shan1395
28-Jun-11 0:46am
View
Hi,
I was trying to validate my XML and Schema thru tool, i gotta below error message
cvc-elt.1: Cannot find the declaration of element 'CRS'.
Any Idea ?.
shan1395
27-Jun-11 21:21pm
View
is this anyway to catch the exception in the code ? bcoz its not throwing anything
shan1395
27-Jun-11 11:12am
View
hi Morl99,
Its not throwing anything or showing any msg to say its validated or not.
shan1395
27-Jun-11 11:11am
View
hi Pete,
thanks for your response,sorry i noticed and try to update <test> BUT COULDN'T update the xml file here.
but my xml file match with xsd file,with case sensitive
shan1395
22-Mar-11 7:00am
View
Awesome thank you so much Sandeep
shan1395
22-Mar-11 5:52am
View
hi Sandeep
Thanks for your comment do you seen my query,am trying to pull values from another table (ADUser) and insert in to Phone table.Your store proc to insert for getting values inline and insert.
shan1395
17-Mar-11 21:31pm
View
here is the code
using System;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
class Program
{
static void Main(string[] args)
{
DataTable users = GetEnabledUsers();
using (SqlConnection cnx = new SqlConnection(@"Data Source=SRV03;Initial Catalog=DEV;Integrated Security=SSPI"))
{
cnx.Open();
using (SqlCommand cmd = cnx.CreateCommand())
{
foreach (DataRow user in users.Rows)
{
if (user["otherPager"] != DBNull.Value && !String.IsNullOrEmpty((string)user["otherPager"]))
{
if (user["mail"] != DBNull.Value && !String.IsNullOrEmpty((string)user["mail"]))
{
cmd.CommandText = "UPDATE Email SET EmailAddress=@mail WHERE EmployeeNumber=@empid";
cmd.Parameters.AddWithValue("@mail", user["mail"]).DbType = DbType.String;
cmd.Parameters.AddWithValue("@empid", user["otherPager"]).DbType = DbType.String;
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
}
if (user["telephoneNumber"] != DBNull.Value && !String.IsNullOrEmpty((string)user["telephoneNumber"]))
{
cmd.CommandText = "UPDATE Phone SET PhoneNumber=@phone WHERE EmployeeNumber=@empid";
cmd.Parameters.AddWithValue("@phone", user["telephoneNumber"]).DbType = DbType.String;
cmd.Parameters.AddWithValue("@empid", user["otherPager"]).DbType = DbType.String;
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
}
}
}
}
cnx.Close();
}
}
static DataTable GetEnabledUsers()
{
//string connectionString = "Provider=SQLOLEDB";
string connectionString = "Provider=SQLOLEDB;Data Source=SRV03;Initial Catalog=DEV;Integrated Security=SSPI";
string searchRoot = "<ldap: dc="yourdomain,DC=com">";//Altered here based on my AD conncetion
string activeUsersFilter = "(&(objectCategory=person)(objectClass=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))";
string attributes = "sAMAccountName, telephoneNumber, mail, otherPager";
string searchScope = "subtree";
string commandText = String.Format("{0};{1};{2};{3}",searchRoot, activeUsersFilter, attributes, searchScope);
DataTable enabledUsers = new DataTable();
using (OleDbDataAdapter dataAdapter = new OleDbDataAdapter(commandText, connectionString))
{
try
{
dataAdapter.Fill(enabledUsers);
}
catch (System.Exception se)
{
Console.WriteLine(se.Message);
}
}
return enabledUsers;
}
}
shan1395
17-Mar-11 21:28pm
View
Ooops sorry it was a connection problem,just changed that but it throws different exception now
Incorrect syntax near '<'.
shan1395
17-Mar-11 21:23pm
View
thanks OriginalGriff,
Ofcoure i replaced all my connection string with SQl and AD.I don't want to paste the string here,that's why i mentioned "your string".
shan1395
16-Mar-11 7:44am
View
thanks for the info dasblinkenlight.
shan1395
16-Mar-11 6:57am
View
Thanks a lot dasblinenlight for all your great help.
Even i have to do periodic update but is that a better way to do ,at present in my mind once the AD is updated in DB the next time runs it will find only date modified or date changed users only and update that particular users only in my DB.
Is that any other way to achieve this ?
shan1395
16-Mar-11 1:54am
View
Thanks a lot for all your help dablinkenlight.
I don't want to deal directly with AD,so i have alternate plan.am going to grab all the active users in AD and store in DB.
then i will query my DB to get the value i want,is that make sense ?
Thanks
shan1395
15-Mar-11 19:52pm
View
Thanks Espen Harlinn,
Am not sure i can use SQL Bulk Copy,the reason is am getting 1000 records from webserivce and update my database.
Still it will open connection 1000 time,is that a right idea for my scenario to use SQL Bulk copy ?
Thanks in Advance
shan1395
15-Mar-11 18:20pm
View
Thanks dasblinkenlight and Dylan Morley,
Based on your both amazing examples and advice modified my code like below,but still it takes approx 4sec to pull the record.
Please advice me
DirectoryEntry entry = new DirectoryEntry(DomainName);
DirectorySearcher searcher = new DirectorySearcher();
searcher.Filter = ("(&(objectClass=user)(otherpager=" + item.EmployeeNumber + "))";
searcher.PropertiesToLoad.Add("telephonenumber");
searcher.PropertiesToLoad.Add("mail");
foreach (SearchResult result in searcher.FindAll())
{
phonenumber = result.GetDirectoryEntry().Properties["telephonenumber"].Value.ToString();
EmailID = result.GetDirectoryEntry().Properties["mail"].Value.ToString();
entry.Dispose();
}
shan1395
15-Mar-11 2:16am
View
i don't know SA...but my code kills Exchange Server
shan1395
10-Mar-11 0:00am
View
Hi Venkatesh,
This is the code
DateTime strDateTime = System.Convert.ToDateTime(item.StartDate);
string conv=System.Convert.ToString (strDateTime);
DateTime dateToSave;
dateToSave = DateTime.Parse(conv);
Here is the below value am getting "dateToSave = {23/03/1992 12:00:00 AM}"
but when it pass it to DB am getting error "Error Converting data type Char to datetime"
shan1395
9-Mar-11 22:56pm
View
figured out some how here is the below code works good
DateTime strDateTime = System.Convert.ToDateTime(item.StartDate);
string conv=System.Convert.ToString (strDateTime);
DateTime dateToSave;
bool canParse = DateTime.TryParse(conv, out dateToSave);
if (canParse)
{
Console.WriteLine("Testok");
}
else
{
Console.WriteLine("Fail");
}
shan1395
9-Mar-11 22:51pm
View
nothing worked me...but if i use the below code
DateTime strDateTime = System.Convert.ToDateTime(item.StartDate); its not showing any error
but i couldn't understand the value am getting is string or already am getting date time ?
shan1395
9-Mar-11 22:41pm
View
thanks for your comment ,sample string in my question anyway.
This is the value am getting for item.startdat =07/03/2011 12:00:00 AM
shan1395
9-Mar-11 20:54pm
View
Thanks for your comment,
changed the code like below
string strDateTime = item.StartDate (can't implictly convert type system.datetime?tostring
DateTime myDateTime = System.DateTime.Parse(strDateTime);
still throwing error (
shan1395
2-Mar-11 17:02pm
View
Thanks for your comment TheRomanian,i was following the exact same way the "http://www.eggheadcafe.com" ask to do.still i couldn't able to pull my method.i can see other methods but this one is to pass the string and retrieve the values
shan1395
2-Mar-11 4:38am
View
Thanks for your response Sridhar,why am not able call some method from webservice ? esp : this one
MLAEmployeeExport,because i have to pass string to this method and get the return value.
Please give me your thoughts,Thanks in Advance
shan1395
2-Mar-11 1:23am
View
Deleted
Ooop sorry here is the method am passing the value
<s:element name="ExportEmployees">
-
<s:complextype>
-
<s:sequence>
<s:element minoccurs="0" maxoccurs="1" name="LoginName" type="s:string">
<s:element minoccurs="0" maxoccurs="1" name="Password" type="s:string">
<s:element minoccurs="1" maxoccurs="1" name="LastExport" nillable="true" type="s:dateTime">
shan1395
2-Mar-11 1:01am
View
when i was trying to call the method
<S:ELEMENT name="ExportEmployees" xmlns:s="#unknown">-<S:COMPLEXTYPE>-
<S:SEQUENCE>
<S:ELEMENT name="LoginName" type="s:string" maxoccurs="1" minoccurs="0" />
<S:ELEMENT name="Password" type="s:string" maxoccurs="1" minoccurs="0" />
<S:ELEMENT name="LastExport" type="s:dateTime" maxoccurs="1" minoccurs="1" nillable="true" />
</S:SEQUENCE>
</S:COMPLEXTYPE>
</S:ELEMENT>
i couldn't able to find ? any help please
shan1395
2-Mar-11 0:57am
View
Thanks Abhinav,yep that helped me.
Moved from stage one to stage two.
I gotta another problem when i call the method
shan1395
1-Mar-11 21:43pm
View
first of all thanks for all your help.There is nothing wrong with that code,if you seen the code above,am not using referenced to read the wsdl file.
I am trying to consume my webservice thru add reference.
What i did here is i add the webreference and call my webservice (wsdl) file.and trying to invoke those webservice in my console application to retrieve the value of the field.
And i have one more question ,how can i create the porxy webservice,bcoz when i call my webservice it return 404 error.
shan1395
24-Feb-11 23:58pm
View
Thanks Nishant
shan1395
24-Feb-11 22:55pm
View
Hi Nishant ,
Embedded your code in to the existing Dll file but its throwing error
The type or namespace name'collection' could not be found
shan1395
24-Feb-11 22:14pm
View
thanks for your suggesting and code,the reason i want to convert this.
Already i have DLL file,i wanna add this one of my method in my existing file
this is the code,i have to include this method in that code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.DirectoryServices;
namespace ActiveDir
{
public class Employee
{
// instance variables
public String name, loginname, firstname;
public String surname;
public string title;
public string company, Org;
public string email, useraccountcontrol;
public string mobile, telephonenumber, pager;
public string city, state, country, postalcode;
// ...
// Constructors
public String FullName()
{
return String.Format("{0}. {1}. {2}. {3}. {4}. {5}. {6}. {7}. {8}. {9}. {10}. {11}. {12}. {13}. {14}.{15} ", name, title, company, surname, email, pager, mobile, telephonenumber, city, state, postalcode, country, loginname, firstname, useraccountcontrol, Org).Trim();
}
public static implicit operator String(Employee value)
{
return value.ToString();
}
public Employee()
{
}
}
public class ActiveDirSearch
{
public ActiveDirSearch()
{ }
public Employee SearchUser(string username)
{
Employee employee = new Employee();
try
{
DirectoryEntry entry = new DirectoryEntry("GC://Test", "Test\\Test", "Ld@Test", AuthenticationTypes.Secure);
System.DirectoryServices.DirectorySearcher search = new System.DirectoryServices.DirectorySearcher(entry);
if (username.Contains("."))
{
string Fname = username.Substring(0, username.IndexOf("."));
Fname = Fname.Replace(" ", "");
string[] splitString = username.Split(new char[] { '.' });
username = splitString[splitString.Length - 1];
string email = Fname + "." + username;
search.Filter = "(mail=" + email + "*" + ")";
}
//--------If condition for Space and Dot search Filter---------------------------------------
if (username.IndexOf(" ") > 0)
search.Filter = "(cn=" + username + ")";
SearchResult result = search.FindOne();
if (result != null)
{
// user exists, cycle through LDAP fields (cn, telephonenumber etc.)
ResultPropertyCollection fields = result.Properties;
foreach (String ldapField in fields.PropertyNames)
{
// cycle through objects in each field e.g. group membership
// (for many fields there will only be one object such as name)
foreach (Object myCollection in fields[ldapField])
{
if (ldapField == "name")
employee.name = myCollection.ToString();
if (ldapField == "sn")
employee.surname = myCollection.ToString();
if (ldapField == "title")
employee.title = myCollection.ToString();
if (ldapField == "company")
employee.company = myCollection.ToString();
if (ldapField == "mobile")
employee.mobile = myCollection.ToString();
if (ldapField == "postalcode")
employee.postalcode = myCollection.ToString();
if (ldapField == "t
shan1395
24-Feb-11 22:11pm
View
Deleted
am sorry i was suppose to write my comment here,forgotten placed it in Solution...Apologies for that
shan1395
24-Feb-11 6:37am
View
please Correct me,if am not followed your logic in the below code
using System;
using System.Text;
using System.DirectoryServices;
namespace activeDirectoryLdapExamples
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter property: ");
String property = Console.ReadLine();
try
{
DirectoryEntry myLdapConnection = createDirectoryEntry();
DirectorySearcher search = new DirectorySearcher(myLdapConnection);
search.PropertiesToLoad.Add("cn");
search.PropertiesToLoad.Add(property);
SearchResultCollection allUsers = search.FindAll();
foreach(SearchResult result in allUsers)
{
if(user.properties["whenCreated"].value > StartDate && user.properties["whenCreated"].value < EndData)
{
user.properties["whenCreated"].value.ToString()
}
}
}
catch (Exception e)
{
Console.WriteLine("Exception caught:\n\n" + e.ToString());
}
}
static DirectoryEntry createDirectoryEntry()
{
// create and return new LDAP connection with desired settings
DirectoryEntry ldapConnection = new DirectoryEntry("rizzo.leeds-art.ac.uk");
ldapConnection.Path = "LDAP://OU=staffusers,DC=leeds-art,DC=ac,DC=uk";
ldapConnection.AuthenticationType = AuthenticationTypes.Secure;
return ldapConnection;
}
}
}
shan1395
24-Feb-11 6:30am
View
Awesome Philip,that was an amazing idea, i was keep on thinking to put condition in Search filter.
This logic works and thank you so much
shan1395
23-Feb-11 19:38pm
View
I never claim the credit for that code ,never ever.
shan1395
23-Feb-11 19:36pm
View
Deleted
i couldn't able to think any other logic here except "IF" condition.
That's the only solution i have
Eg: if string comes like JOE WILL.SMITH
Then Username : Smith and Fname: JOEWILL
IF (Sn=username)&(givenname=Fname)
{
search.Filter = "(sn=" + username + ")";
}
This is what in my mind but doing IF and cross check the value again AD is the problem for me.
shan1395
23-Feb-11 19:31pm
View
Deleted
seriously am not sure to use IF statement for Search filter.
shan1395
23-Feb-11 18:00pm
View
Ignore the previous comment,i remodified the code like below.
if (username.Contains("."))
{
string Fname = username.Substring(0, username.IndexOf("."));
Fname = Fname.Replace(" ", "");
string[] splitString = username.Split(new char[] { '.' });
username = splitString[splitString.Length - 1];
search.Filter = "(sn=" + username + ")&(givenname=" + Fname + ")";//Throwing Exception
//This statement pass the value
search.Filter = "(sn=" + username + ")";
}
if (username.IndexOf(" ") > 0)
search.Filter = "(cn=" + username + ")";
If i user firstname and last name in search filter,its throwing exception.but if i use only first name or last name,then it returns output.
Am not sure the exact syntax for search filter with conditions
shan1395
23-Feb-11 17:53pm
View
Mkgoud,
Search filter throwing exception.
Have modified code little bit like this
if (username.Contains("."))
{
string Fname = username.Substring(0, username.IndexOf("."));
Fname = Fname.Replace(" ", "");
string[] splitString = username.Split(new char[] { '.' });
username = splitString[splitString.Length - 1];
search.Filter = "(sn=" + username + ")&(givenname=" + Fname + ")";//Throwing Exception
//This statement pass the value
search.Filter = "(sn=" + username + ")";
}
if (username.IndexOf(" ") > 0)
search.Filter = "(cn=" + username + ")";
shan1395
23-Feb-11 17:40pm
View
Hi GenJerDan,
mkgoud code is retrieve the value for Fname but when i pass it to my search filter ,throws error like
"The name (fname) doesn't exist in the current context"
am not sure why its not recoganize the fname.
shan1395
23-Feb-11 16:54pm
View
Thanks mkgoud again you shown me the right path.
I have problem in my search filter its not accepting "Fname",it throws error
"The name (fname) doesn't exist in the current context"
shan1395
23-Feb-11 16:47pm
View
If you seen my code,am handling three different (actually 4) scenario.
parameter always pass like
Joe will.smith
Joewill.smith
joe will smith
that why i used if condition in my filter.if string comes with "dot" then i will split the string (first name and last name) and compare against AD to retrieve the user.
shan1395
23-Feb-11 8:09am
View
i was testing this code with out replace ,it works fine,"mkgoud" corrected my mistake
so the whole code is suppose to be like this
if (username.Contains("."))
{
string Fname = username.Substring(0, username.IndexOf("."));
Fname = Fname.Replace(" ","");
string[] splitString = username.Split(new char[] { '.' });
username = splitString[splitString.Length - 1];
}
if (username.IndexOf(" ") > 0)
search.Filter = "(cn=" + username + ")";
else
search.Filter = "(sn=" + username + ")" & "(givenname=" + Fname + "));
shan1395
23-Feb-11 8:04am
View
thanks a lot for your response,is this my search filter condition is correct ?
search.Filter = "(sn=" + username + ")" & "(givenname=" + Fname + ")); (some how i have doubt in this line too)
shan1395
23-Feb-11 7:51am
View
Thanks philip,def this works (haven't yet test in my end),i will let you know shortly after test from my end.Am going to use this function in my existing dll file and retrieve only active users.
shan1395
23-Feb-11 7:00am
View
Hi Philip,
Thanks for your response,i don't think so "UserPrincipal" will tell you the account is active or not.
Pardon me if am wrong,i was going thru msdn (suggested by you),it doesn't help me much.Usally "UserAccountcontrol" tells you the account is active or deactive (based on 512 or 514).But in my case i was trying to retrieve the value from AD,but its not returning anything.
shan1395
22-Feb-11 20:34pm
View
what is the best approach to do that,any help much appreciated.
shan1395
22-Feb-11 20:14pm
View
Hi SA,
I gotta few more things to add up my class library file.
Like "Retrieve all users"
"Retrieve users based on OU"
"Retrieve all terminated user based on a start date and also on date range"
shan1395
22-Feb-11 19:15pm
View
Thanks SA
shan1395
22-Feb-11 17:28pm
View
Hi Alan,
How can i handle the Null,if user is not in the AD then am returning NULL,and NULL is returning it throws eception.
How can i handle this ?any help appreciated
shan1395
22-Feb-11 17:23pm
View
Deleted
Sorry ignore the previous post,it returning values.i just written the output.
Thanks a lot
shan1395
22-Feb-11 17:12pm
View
Deleted
Am not sure what's wrong,its not return any value.
Am passing Joe Smith and it should return like (Administrator,Joe,Smith).
when i was debugging still the value shows "Joe Smith",look like its not getting the value from my class library
shan1395
22-Feb-11 16:59pm
View
Deleted
Thanks Alan,
am going to retrieve bunch of fields from AD,so in that case i have to format all the strings?
I totally forgot that am returning an object and call as string.
Thanks again Alan.
shan1395
21-Feb-11 23:46pm
View
I checked Char.IsUpper won't help me,correct me if am wrong .
My approach is create If statement for "." and split the string.like John Doe.Smack,am going to grab "Smack" and in my filter am going to use "SN"=Smack.
If there is no "." then i will pass the whole string to another filter "cn"= Username
how is that sound ?
shan1395
21-Feb-11 23:23pm
View
Thanks Henry
Am not sure ,i explained the problem clearly.The problem for me is not Upper or lower case. Its basically space and ".". they can search AD user like JohnDoe.Smack or John Doe.Smack or John Doe Smack.
anyway i have to retrieve the user information,that all i want to do.
shan1395
21-Feb-11 23:12pm
View
Its pretty much similar,even used "improve question"but not sure ,thrown an error,that's why i choosed New Question
shan1395
21-Feb-11 22:54pm
View
hey i gotta one more question.
I got a new scenario
For example AD name: John Doe smack
Scenario 1:JohnDoe.Smack
scenario 2: John Doe Smac
scenario 3: JohnDoe.Smack
Scenario 4: John Doe.Smack
How can i achieve all the scenairo's
shan1395
21-Feb-11 1:32am
View
Hi Yusuf,
I seen the example you mentioned,now i gotta problem how to execute my c# class library file,please help .Am damn new to .Net
Show More