Monday, March 26, 2012
How to get the OU information on a usr into my SQL VIew
I am reading AD Users, who are organised in different OU in my AD.
In the OU i have some organisational information that i would like to link
together
with my AD Users when i make my SQL view.
How can i join these 2 information in my SQL View ?Could you please provide schema, data and expected results.
Thanks
Peter
"sdane" wrote:
> Hi
> I am reading AD Users, who are organised in different OU in my AD.
> In the OU i have some organisational information that i would like to link
> together
> with my AD Users when i make my SQL view.
> How can i join these 2 information in my SQL View ?|||sure thing,
I have a domain int.dem.local
here i have a OU called Finance Department. On the OU there are info like
City=Roskilde and State/Proviens=2. Floor.
In the OU i have some users with the normal fields filled out like first
name, last
name, User Logon name.
In the AD these information is kept in 2 places. I would like to have a SQL
View
that shows me records like
first name, last name, User Logon name, (OU) City, (OU) State/provins
This way i can maintaine the generel information about my users location a
single
place and still have all the information in one record in my sql.
Is this possible ?
Is this want you were asking for ?
"Peter Nolan" wrote:
> Could you please provide schema, data and expected results.
> Thanks
> Peter
> "sdane" wrote:
>|||Apologies for not getting back sooner, minor problem to sort out.
I think we are talking cross purposes here. For any view to work it needs to
be in a SQL Table with data in it, I do not think it can be otherwise unless
its part of a linked server.
So could you provide some table structure i.e.what it looks like in SQL
Server tables, and possibly some play data.
Peter
"sdane" wrote:
> sure thing,
> I have a domain int.dem.local
> here i have a OU called Finance Department. On the OU there are info like
> City=Roskilde and State/Proviens=2. Floor.
> In the OU i have some users with the normal fields filled out like first
> name, last
> name, User Logon name.
> In the AD these information is kept in 2 places. I would like to have a SQ
L
> View
> that shows me records like
> first name, last name, User Logon name, (OU) City, (OU) State/provins
> This way i can maintaine the generel information about my users location a
> single
> place and still have all the information in one record in my sql.
> Is this possible ?
> Is this want you were asking for ?
> "Peter Nolan" wrote:
>|||I am using ADSI til make a linked server to connect to my active directory.
And then i have a SQLView to get the data from a user in the AD.
The AD user info is
givenname = Hans
sn = Jensen
SAMAccountname = dom.hans
This user is located in a Organisational Unit (OU) in my AD. On this OU ther
e
are info like
OU = Brugere
City = Copenhagen
State/Provinse = 2.Floor
What i want is to make a SQL View that can give me records were these two
pieces of info is joined into one record like
givenName sn SAMAccountname City
State/Provinse
----
--
Hans Jensen dom.hans Copenhagen 2.Floor
I made my Linked ser with these sql scripts:
sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5', 'ADSDSOObject',
'DomServer'
sp_addlinkedsrvlogin ADSI, false, 'sa', 'AD_Reader', 'Reader'
After this a make the SQL view using this sql script:
create view v_ADSI(SAMAccountName, givenname, sn)as
SELECT * FROM OpenQuery(
ADSI_INST,'<LDAP://ou=Brugere,dc=lpb,dc=local>;(&(objectCategory=Person)(obj
ectClass=user));SAMAccountName, givenname,sn;subtree')
This gives me the ad users info, but have do i get the OU info and link it
with the
user info.
"Peter Nolan" skrev:
> Apologies for not getting back sooner, minor problem to sort out.
> I think we are talking cross purposes here. For any view to work it needs
to
> be in a SQL Table with data in it, I do not think it can be otherwise unle
ss
> its part of a linked server.
> So could you provide some table structure i.e.what it looks like in SQL
> Server tables, and possibly some play data.
> Peter
> "sdane" wrote:
>
Friday, March 23, 2012
How to get the Data in Values?
hi
i have creat some code to get data from Database like:
Dim strNewsIDAsInteger = Request.QueryString("ID")
Dim NewsconnAsNew System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("SiteSQLServer").ToString())Dim NewscmdAsNew System.Data.SqlClient.SqlCommand("SELECT FROM News (NewsGroupID, NewsTitle, News, NewsPosition) WHERE NewsID=strNewsID", Newsconn)
Now i wanna get Data in Values
Newsconn.Open()
Dim NewsGroupIDAsInteger = ???
Dim NewsTitleAsString = ???
Dim NewsAsString = ???
Dim NewsPositionAsInteger = ???
Please let me know how?Newsconn.Close()
Dim NewscmdAsNew System.Data.SqlClient.SqlCommand("SELECT FROM News (NewsGroupID, NewsTitle, News, NewsPosition) WHERE NewsID=strNewsID", Newsconn)
DrZ3D:
I'm not a VB programmer, so someone else will have to help you with the VB syntax.
But the sql command is in a format I've never seen before.
I think you should be issuing this select statement:
"SELECTNewsGroupID, NewsTitle, News, NewsPositionFROM News WHERE ...
|||you have an SQL connection and a querry.
So what you need now is a SQL Reader and then just loop throght this record set that is returned to get the values.
SqlDataReader readerAs new SqlCommand(query, conn)reader.ExecuteReader() if (reader.HasRows){// get the values here }
but are you getting 1 row returned or more?|||
my conection is work and i get only one rowe from database
i only wana know how put the record in a value
thanks
|||I'm not sure how will you provide the value forstrNewsID, so I'm leaving the problem on you. Other than that your modified code is below:
Dim strNewsIDAs Integer = Request.QueryString("ID")
Dim NewsconnAs New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("SiteSQLServer").ToString())Dim NewscmdAs New System.Data.SqlClient.SqlCommand("SELECT NewsGroupID, NewsTitle, News, NewsPosition FROM News WHERE NewsID=strNewsID", Newsconn)
dim sdr as SqlDataReader
Dim NewsGroupIDAs Integer
Dim NewsTitleAs String
Dim NewsAs String
Dim NewsPositionAs Integer
Newsconn.Open()
sdr = Newscmd.executeReader()
if sdr.HasRows then
sdr.read()
NewsGroupID = sdr("NewsGroupID")
NewsTitle = sdr("NewsTitle")
News = sdr("News")
NewsPosition = sdr("NewsPosition")end if
sdr.close()
newscommand.dispose()
Newsconn.Close()
Hope you will correct any syntactical errors.
Hope this will help.
Friday, March 9, 2012
How to get queue handle by queue name
I have a trace in SQL Server 7 that starts with the server start up. I know
the queue definition name, but i don't the queue_handle.
I need the queue_handle to stop the trace if required in between.
Thanks in advance.
Pushkar
Pushkar wrote:
> Hi
> I have a trace in SQL Server 7 that starts with the server start up.
> I know the queue definition name, but i don't the queue_handle.
> I need the queue_handle to stop the trace if required in between.
> Thanks in advance.
> Pushkar
xp_trace_enumqueuehandles - to enum queue handles
xp_trace_enumqueuedefname
xp_trace_getqueueautostart
xp_trace_getqueuedestination - or any of the get* functions to return
info about the queue
David Gugick
Quest Software
www.imceda.com
www.quest.com
Friday, February 24, 2012
How to get INSERT-SQL for rows?
Hi
I'm using the SQL Server 2005 Express edition.
I've manually created some rows in a table "Books".
If I right-click on "dbo.Books" and choose "Script Table As --> Create To --> New Query Editor Window", I get the SQL for creating that table.
But how do I get the INSERT-SQL for the rows already inserted?
Kind Regards
hi,
there's no support for that task, you have to do it your self..
or you can have a look at a free prj of mine, amInsert, available at http://www.asql.biz/en/Download2005.aspx
regards
|||Hi Andrea
Thanks for your ImInsert!
It worked perfectly!
Kind Regards
Sunday, February 19, 2012
How to get Extended error information from stored procedure
Hi
I have a stored procedure in SQL server 2005. It works fine when I execute it from the Management Studio.
But when executing it from ASP.NET code like this:
.... Of course more code is executed before this call ....
int retVal =this.odbcCreateDataBaseCommand.ExecuteNonQuery();
retVal is -1. But -1 doesn't really tell me what the problem is?
Is there anyway to get extended error information so I can figure out whats going wrong?
(The stored procedure was working fine in SQL server 2000 before I upgraded to SQL server 2005. I use .NET Framework 1.1 and ODBC Sql Native Client to access the 2005 server.)
Regards
Tomas
My own thought...
Maybe .NET Framework 1.1 and SQL Server 2005 and ODBC SQL Native Client have poor compatibility...
Anyone out there with experience/insight?
Thanks
Tomas