[jcifs] Contribution: LsaLookupNames

Giampaolo Tomassoni Giampaolo at Tomassoni.biz
Fri Feb 1 00:00:53 GMT 2008


Dears,

I'm attaching to this message my own contribution to the jcifs project as a
patch against jcifs-1.2.17.

The contributed code allows to obtain SIDs from domain names a-la
LsaLookupNames().

Returned SIDs have their domainName and acctName fields correctly set, apart
the fact that the casefold of acctName may not be exactly the one stored in
the server or domain. A further resolve() call on the returned SIDs must be
issued in order to obtain the exact acctName.

Example of use:

	NtlmPasswordAuthentication ntlm = new
NtlmPasswordAuthentication("DOMAIN", "AUser", "ItsPassword");
	DcerpcHandle dceHandle = DcerpcHandle.getHandle(
		"ncacn_np:thedc[\\PIPE\\lsarpc]",
		ntlm
	);
	LsaPolicyHandle lsaHandle = new LsaPolicyHandle(
		dceHandle,
		"\\\\thedc",
		0x00000800	// POLICY_LOOKUP_NAMES
	);

	SID sids[] = SID.getFromName(
		dceHandle,
		lsaHandle,
		new String[] { "MaybeAUser", "OrPherapsAGroupOfUsers",
"OrMaybeEvenAComputer" }
	);

Regards,

PS (mostly to Mike): I got lost in chasing all that SmbSessions and
SmbTransports and SmbPipeFiles and Handles, thereby I give up. I would
personally welcome anybody willing to contribute the "glue" between an
authenticated SmbSession and a DcerpcHandle. At the moment I'll use a
(Argh!) specific pre-defined user to resolve names...

-------------------------------------
Giampaolo Tomassoni - I.T. Consultant
Piazza VIII Aprile 1948, 4
I-53043 Chiusi (SI) - Italy
Tel/Ph: +39-0578-21100

MAI mandare un messaggio a:
NEVER send an e-mail to:

 rainbowl at tomassoni.biz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jcifs-1.2.17+lookupnames.patch
Type: application/octet-stream
Size: 9042 bytes
Desc: not available
Url : http://lists.samba.org/archive/jcifs/attachments/20080201/8110ef8a/jcifs-1.2.17lookupnames.obj


More information about the jcifs mailing list