|
i am working on Active director multiple domain for search user.but Its produced Error:- There is no such object on the server. -2147016656
Please Help me.
Code:-
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
FindUser("dev\t", True)
End Sub
Public Function FindUser(ByVal principalname As String, ByVal useGC As Boolean) As DirectoryEntry
Try
Dim searchRoot As DirectoryEntry
Dim searcher As DirectorySearcher
Dim name() As String
Dim ncName As String
name = principalname.Split("\")
If name.Length <> 2 Then
Throw New ArgumentException("principalname is not in the correct format", principalname)
End If
ncName = ResolveNetBiosNameToDN(name(0))
searchRoot = GetDirectoryEnTry(ncName, useGC)
searcher = New DirectorySearcher(searchRoot, String.Format("(&(objectCategory=person)?(objectClass=user)? (sAMAccountName={0}))", name(1)), New String() {"distinguishedName"}, SearchScope.Subtree)
Try
Return searcher.FindOne().GetDirectoryEntry()
Catch ex As NullReferenceException
Throw New ArgumentException("The given username was not found", "principalname", ex)
End Try
Catch ex As Exception
End Try
End Function
Private Function ResolveNetBiosNameToDN(ByVal netbiosName As String) As String
Try
Dim authenticationType As New System.DirectoryServices.AuthenticationTypes
If ConfigurationManager.AppSettings("AD_UseSecureConnection").ToUpper.Trim.Equals("TRUE") Then
authenticationType = AuthenticationTypes.Secure
Else
authenticationType = AuthenticationTypes.None
End If
Dim rootDSE As New DirectoryEntry(ConfigurationManager.AppSettings("AD_IP").Trim, ConfigurationManager.AppSettings("AD_UserName").Trim, ConfigurationManager.AppSettings("AD_Password").Trim, authenticationType)
' Dim configurationNamingContext As String = CType(rootDSE.Properties("configurationNamingContext").Value, String)
Dim defaultNamingContext As String = CType(rootDSE.Properties("distinguishedName").Value, String)
'defaultNamingContext = defaultNamingContext.Split(",")(0)
' Dim Str As String =
Return CType(GetDirectoryEnTry(String.Format("CN={0}, CN=Partitions, {1}", netbiosName, defaultNamingContext)).Properties("nCName").Value, String)
' Return DirectCast(GetDirectoryEnTry(String.Format("CN={0}, CN=Partitions, {1}", netbiosName, DirectCast(configurationNamingContext.Properties("distinguishedName").Value, String))).Properties("nCName").Value, String)
'Dim ss As String = "sada"
Catch ex As System.Runtime.InteropServices.COMException
If CInt(ex.ErrorCode) = 2147950640 Then
Throw New ArgumentException("The given netbios name was invalid", "netbiosName", ex)
Else
Throw
End If
Catch ex As Exception
' return (string) GetDirectoryEntry(string.Format("CN={0}, CN=Partitions, {1}", netbiosName, (string) ConfigurationNamingContext.Properties["distinguishedName"].Value)).Properties["nCName"].Value;
End Try
End Function
Public Function GetDirectoryEnTry(ByVal distinguishedName As String) As DirectoryEntry
Return GetDirectoryEnTry(distinguishedName, False)
End Function
Public Function GetDirectoryEntry(ByVal distinguishedName As String, ByVal useGC As Boolean) As DirectoryEntry
Try
Dim path As String
path = IIf((useGC), "GC://", "LDAP://")
Dim _server As String = "dev.eventure.biz"
If _server IsNot Nothing Then
path += _server
End If
If (Not path.EndsWith("/")) AndAlso (distinguishedName <> "") Then
path += "/"
End If
path += distinguishedName
If path.EndsWith("//") Then
path = path.Remove(path.Length - 2, 2)
End If
Return New DirectoryEntry(path, "dev\adadmin", "password_1234", AuthenticationTypes.Secure)
Catch ex As Exception
End Try
End Function
Thanks
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com
|
|
|
|
|
I have a gridview that has some prices that is dispayed as strings.
In the database these prices are nvarchar datatype.
I need to sort them in the gridview as numbers because they are not sorted correctly as strings but at the moment I can't change this datatype in the database. So is there any workaround to sort this column as numbers? how?
|
|
|
|
|
Wouldn't you just convert the string to an int, if so Convert.ToInt32...something like that maybe
|
|
|
|
|
how can I do that?
do I have to do it inside the sorting event??
How..details plz.
thanks
|
|
|
|
|
Try sherin's suggestion below first to see if that helps you, if not convert string to int
|
|
|
|
|
Put it around your value e.g. Convert.ToInt32(value in here)
|
|
|
|
|
Convert your price field to integer in the query...
SELECT Your_Fields FROM Your_Table WHERE Your_Condition ORDER BY CAST(Your_Field AS INT)
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
The problem is that I'm using the SortExpression property of the gridview's databound item. The sortExpression property only takes that column name to be sorted so how can I add this Cast(field As Int)??
|
|
|
|
|
Try casting in your select
select column1, column2,CAST(columnn3 AS INT) as column3 from table
This will return an int column to your grid, problem solved.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Got It
CAST In Your Select Sql Query
Select field1,CAST(Price AS INT) As Price,.......
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Thanks a lot, I think this is gonna work.
|
|
|
|
|
Thats what I said - do the cast in the query, it then returns the correct datatype.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Your design is broken. Why you need to keep prices in NVarchar field ? How are you binding this grid view ? Using a DataTable ? If yes, after filling the data table, change the column type to integer or double. So gridview can sort it correctly.
|
|
|
|
|
I need to know how can I bind my gridview from a pop up window?
I have a gridview on a parent page and then a user can open a pop up window to perform some changes on the gridview in the parent page after that he closes the window. Right then I need to bind the gridview on the parent page to view the changes that the user did from the pop up window.
How can I do that?
|
|
|
|
|
OK so you want the following to happen:
User views gridview in mainpage
user edit gridview in new window
user views gridview in mainpage with updated values.
The thing is when the new window closes its not very easy to navigate a user back to the mainpage and then refresh that page to reflect the new changes.
Instead of opening a new window(which may be blocked by pop-up blocker) keep them in the same window and user query string to transfer the values.
|
|
|
|
|
thanks for the repy, but there is no way I can do all the editing on the same page. The only way is to use a pop up window.
Is there any other solution for this?
|
|
|
|
|
No, because as soon as you open a pop-up window your application is split in two and they can now continue navigating around the mainpage even with the pop-up open.
best to keep it all in the same window anyway
|
|
|
|
|
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string s17 = Request.Form["scheck"].ToString();
scheck.Value = s17;
Response.Write(s17);
string s18 = Request.Form["sacc1"].ToString();
sacc1.Value = s18;
Response.Write(s18);
string s19 = Request.Form["schild"].ToString();
schild.Value = s19;
Response.Write(s19);
string s = Session["child"].ToString();
//Response.Write(s);
//Response.Write(s19);int.Parse(Request.Form["schild"])==1
if (int.Parse(s19)== 1)
{
Session["a"] = ctcchild1.name;
Session["b"] = ctcchild1.age;
Session["c"] = ctcchild1.college;
}
else if (int.Parse(s19)==2)
{
Session["d"] = ctcchild2.name;
Session["e"] = ctcchild2.age;
Session["f"] = ctcchild2.college;
}
//else
//{
else if (2<int.parse(s19)><= 3)
{
Session["g"] = ctcchild3.name;
Session["h"] = ctcchild3.age;
Session["i"] = ctcchild3.college;
}
else if(int.Parse(s19) == 4)
{
Session["j"] = ctcchild4.name;
Session["k"] = ctcchild4.age;
Session["l"] = ctcchild4.college;
}
how to apply condition at this place
plz tell me
thanks
|
|
|
|
|
what do you mean by
gaurav mangal wrote: how to apply condition at this place
|
|
|
|
|
gaurav mangal wrote: if (int.Parse(s19)== 1)
{
Session["a"] = ctcchild1.name;
Session["b"] = ctcchild1.age;
Session["c"] = ctcchild1.college;
}
else if (int.Parse(s19)==2)
{
Session["d"] = ctcchild2.name;
Session["e"] = ctcchild2.age;
Session["f"] = ctcchild2.college;
}
//else
//{
else if (2<int.parse(s19)><= 3)
{
Session["g"] = ctcchild3.name;
Session["h"] = ctcchild3.age;
Session["i"] = ctcchild3.college;
}
else if(int.Parse(s19) == 4)
{
Session["j"] = ctcchild4.name;
Session["k"] = ctcchild4.age;
Session["l"] = ctcchild4.college;
}
if you have conditions like this, how would u retrieve correct data back from Session ???
apr ~ asp
|
|
|
|
|
then plz tell me what should i do.
|
|
|
|
|
actually i am taking value from one page to other page using sessions .
but i want at secont page that if the value of session["s1"] ==2 to webcontrol should be generate two times.and it ==3 then usercontrols should be generate 3 times .so i have to apply condition :
if(session["s1"]==1)
{
}
if(1<session["s1"]><=2)(error)
{
}
now i get error:
Operator '|' cannot be applied to operands of type 'bool' and 'int'
what should i do.
thanks
|
|
|
|
|
gaurav mangal wrote: if(1<session["s1"]><=2)
That if condition is totally wrong!
I'm not able to understand what you are trying to do here.
Can you please explain?
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
thanks for the response.
actually i want that if a user select 2 from dropdownlist or 3 or 4 .
then at second page 2 or 3 or 4 usercontrol will create .so i have
tha value of dropdownlist in sessions .
and want to apply condition on that .
this is the code .
or you suggest what should do.
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string s17 = Request.Form["scheck"].ToString();
scheck.Value = s17;
Response.Write(s17);
string s18 = Request.Form["sacc1"].ToString();
sacc1.Value = s18;
Response.Write(s18);
string s = Session["child"].ToString();
//Response.Write(s);
//Response.Write(s19);int.Parse(Request.Form["schild"])==1
if (int.Parse(s)== 1)
{
Session["a"] = ctcchild1.name;
Session["b"] = ctcchild1.age;
Session["c"] = ctcchild1.college;
}
else if (1<int.parse(s)><=2)(error)
{
Session["d"] = ctcchild2.name;
Session["e"] = ctcchild2.age;
Session["f"] = ctcchild2.college;
}
//else
//{
else if (2<int.parse(s)><=3)(error)
{
Session["g"] = ctcchild3.name;
Session["h"] = ctcchild3.age;
Session["i"] = ctcchild3.college;
}
else if(int.Parse(s19) == 4)
{
Session["j"] = ctcchild4.name;
Session["k"] = ctcchild4.age;
Session["l"] = ctcchild4.college;
}
|
|
|
|