HTML Help...
Author
Discussion

slinky

Original Poster:

15,704 posts

273 months

Thursday 30th September 2004
quotequote all
Afternoon..

Fecking about with an Intranet type thingy and would like to automatically harvest the domain logon for certain sections of the site, ie "Hello $logged-on-user$" if you know what I mean...

Any ideas how we could "simply" do this?

TIA,

slinky

anonymous-user

78 months

Thursday 30th September 2004
quotequote all
If you're doing it in ASP on IIS, you can use the Request.ServerVariables("AUTH_USER") or Request.ServerVariables("LOGON_USER").

For more, see www.devguru.com/Technologies/asp/quickref/request_servervariables.html

Plotloss

67,280 posts

294 months

Thursday 30th September 2004
quotequote all
bit of vbscript to get current user from the windows API?

m12_nathan

5,138 posts

283 months

Thursday 30th September 2004
quotequote all
I've got some asp vbscript to collect a username and change it into a full name which will work on your intranet - I can post it tomorrow if you want?

slinky

Original Poster:

15,704 posts

273 months

Thursday 30th September 2004
quotequote all
m12_nathan said:
I've got some asp vbscript to collect a username and change it into a full name which will work on your intranet - I can post it tomorrow if you want?


That'd be great if you could...

cheers,

slinky

m12_nathan

5,138 posts

283 months

Friday 1st October 2004
quotequote all
See below:

Dump this in an include file at the beginning of the page, you can then use the variables sUserName, sSurname, sFirstName later in your page. In our case the fullname of the user is stored as surname firstname so there is some code to switch that about - you can amend that depending on how usernames are populated in your domain.



m12_nathan

5,138 posts

283 months

Friday 1st October 2004
quotequote all
<%
'Used to collect user details

'response.AddHeader "WWW-Authenticate","Negotiate,NTLM"

Dim sUserID,sUserName,sSurname,sFirstName,iUsrGrpTot,grp,iPos,bIsQMP

sUserId = ucase(Trim(Request.ServerVariables("LOGON_USER")))

If sUserID="" then
response.write "<br>Error getting User ID<br>"

else

Set objUser = GetObject("WinNT://" & Replace(sUserId, "", "/" ))

sUserName=objUser.FullName

'Get the groups
iUsrGrpTot=0
For Each grp In objUser.Groups
iUsrGrpTot=iUsrGrpTot+1
Next

'Is this user a site admin?
bIsQMP=0

iPos=0
ReDim aUsrGrp(iUsrGrpTot)
For Each grp In objUser.Groups
'response.write grp.Name
aUsrGrp(iPos)=grp.Name
If UCase(grp.name)="DOMAINGROUPNAMEHERE" Then
bIsQMP=1
End if
iPos=iPos+1
Next

Set objUser = Nothing


iPos=InStr(sUserName, " ")

If iPos>0 Then
sSurname=Mid(sUserName,1,iPos-1)
sFirstName=Mid(sUserName,iPos+1)
sUserName=sFirstName & " " & sSurname
end If

Set iPos=Nothing

End if
%>